Infatuation Rules
Photo by Julia Volk Pexels Logo Photo: Julia Volk

What are the four commonly used flags?

This course focuses on four key arithmetic flags: Zero, Carry, oVerflow, and Negative: Note that not all flags are changed by all operations.

What year of marriage is most common for divorce?
What year of marriage is most common for divorce?

While there are countless divorce studies with conflicting statistics, the data points to two periods during a marriage when divorces are most...

Read More »
How do you know she's not the one?
How do you know she's not the one?

12 Signs She Is Not The One It's Hard To Keep Conversation Going. ... The Thought Of Settling Down Makes You Uncomfortable. ... You Are The One...

Read More »

CS3432 Computer Architecture I Syllabus ‎ > ‎ Course Outline and Timetable ‎ > ‎ Arithmetic Flags Note that not all flags are changed by all operations. For example, arithmetic (add, subtract) operations tend to update all flags, logical operations (XOR) update some flags, and data movement instructions generally do not modify any flags whatsoever. If in doubt, consult the documentation provided by the CPU manufacturer. Zero (Z flag) Z (Zero): true if the result is equal to zero, Useful for equality testing (if A = B, Z is set after subtracting them) detecting last iteration of loop (when decrementing to zero) determining if the result of some bitwise operation is zero Carry (C flag) Big idea: Carry is used to indicate whether the result of an unsigned operation is not representable If adding a += b, carry will be set iff a, b, and the result are interpreted as unsigned, and correctly representing the result requires more bits than are available in the destination..

For example: .

mathematically: 0xfd + 3 = 0x100 = 256

However, if the result register has only 8 bits, then the result will be zero with a carry Thus, for a byte operation, the carry flag will contain the ninth bit If subtracting a -= b, the operation will borrow if a < b when a and b are interpreter as unsigned values Because the result "ought" to be negative. However, there are no negative unsigned numbers so the result will not be properly represented.

The Carry flag is frequently used to indicate when borrow occurs

on the MSP430...

C=0 when subtraction borrows

C=1 otherwise

beware: on some processors C is set the opposite way

C=1 when a subtraction borrows,

C=0 otherwise

Examples:,

mathematically, 0x08 - 0x09 = -1

but there is no "unsigned" -1

and (if all operands are 8 bits), the result will be 0xff (255) and borrow will occur

in contrast, 0x09 - 0x08 = 1

and the result will be 1 (correct!)

and borrow will not occur

Implications for relational operators

Unsigned subtraction: A-B:

What can I flirt over text?
What can I flirt over text?

One of the best ways to invoke a flirty vibe over text is to talk about the time you've spent together. Remind them of how special the experience...

Read More »
Is Miss for unmarried?
Is Miss for unmarried?

Both “Miss” and “Ms.” apply to women who are unmarried or whose marital status is unknown. Whichever you choose depends on the preference of the...

Read More »

If A < B, then the result ought to be negative, so borrow will occur

then the result ought to be negative, so borrow will occur

If B <= A, then the result ought to be non-negative, so borrow will not occur

Subtract in opposite order to determine B < A or B >=A.

Rotate right instruction: rotates through carry

The previous value of carry becomes the new value for the most significant bit The previous value of the least significant bit becomes the new value for carry

Useful for shifting multi-word integers to the right

On the MSP430: to shift in a zero, the carry must be cleared. Most easily done by comparing a value with itself. 1111 1111 1111 1110

+ 0000 0000 0000 1110

------------------------

0000 0000 0000 1100 and a '1' carried out

65534

+ 14

--------

Indicates if the result is negative.

If a result is negative, it's most significant bit (MSB) is true

Bit 15 for word operations

Bit 7 for byte operations

N (Negative): true if the result's most-significant bit is 1 (True)

Implication for relational operators: when subtracting 2's complement numbers A - B If A < B, the result is negative (and the N flag is set) If A >= B, the result is NOT negative (may be zero) Operand order must be reversed ( B-A ) to detect A > B and A <= B.

0000 0000 0000 1100

- 0000 0000 0000 1101

------------------------

1111 1111 1111 1111

0xC

- 0xD

---------

(N=1) 0xFFFF

12

- 13

------

-1

Warning: If result of an addition or subtraction is out of range (a condition described below called overflow), then the negative flag's meaning is complimented For details of this phenomenon, see the section on oVerflow below. oVerflow (V flag): The result of an addition or subtraction operation (i.e. ADD, SUB or CMP), the can "overflow" the range of representable values. When this occurs, the result's sign is wrong. These operations set the oVerflow (V) flag to The result of an addition or subtraction operation (i.e. ADD, SUB or CMP), the can "overflow" the range of representable values. When this occurs, the result's sign is wrong. These operations set the oVerflow (V) flag to true when overflow occurs

false otherwise Consider the following example:

Why does a dumper use no contact?
Why does a dumper use no contact?

Breaking up in any kind of relationship is not easy, whether you are the dumper or the dumpee. This may explain why the no contact rule psychology...

Read More »
What does 70/30 mean in a relationship?
What does 70/30 mean in a relationship?

Being together might be obvious, but being apart from each other can help you not only work on yourself, but keep that “spark” alive in your...

Read More »

0111 1111 1111 1111

+ 0000 0000 0000 0001

------------------------

1000 0000 0000 0000

32767

+ 1

--------

(V=1) -32768

More specifically Arithmetic operations can set 1-bit flags that are useful for characterizing the result. This course focuses on four key arithmetic flags: Zero, Carry, oVerflow, and Negative:Note that not all flags are changed by all operations. For example, arithmetic (add, subtract) operations tend to update all flags, logical operations (XOR) update some flags, and data movement instructions generally do not modify any flags whatsoever. If in doubt, consult the documentation provided by the CPU manufacturer. ADD(.B),ADDC(.B), CMP(.B) V=1 when the result of :

Positive + Positive is a Negative

Negative + Negative is a Positive

V=0 otherwise. SUB(.B),SUBC(.B),CMP(.B) V=1 when the result of

Positive – Negative is a Negative

Negative – Positive is a Positive Otherwise

V=0 othewise Key observation critical for arithmetic comparison V == N indicates that result should have been non-negative

N=V=0: If V=0, then N (0) is correct

N=V=1: If V=0, then N (1) is wrong

V != N indicates that the result should have been negative

V=0, N=1: If V=0, then N (1) is correct

V=1, N=0: If V=0, then N (0) is incorrect 0111 1111 1111 1111

+ 0000 0000 0000 0001

------------------------

1000 0000 0000 0000

32767

+ 1

--------

(V=1) -32768 Practice practice problem - conditional branch based on long comparison See Unsigned addition and flags exercise The bits that represent each flag are stored in the register file in the CPU, specifically in register 2, AKA the Status Register (SR)

Be aware that some operations set multiple flags at once

Check pages 5-7 of link for more details: http://eleceng.dit.ie/frank/msp430/msp430.pdf (2): Addition and flags exercise practice problem - conditional branch based on long comparison Subpages

What are at least 3 signs of an unhealthy friendship?
What are at least 3 signs of an unhealthy friendship?

Here's a look at some other things a toxic friend might do: Put you down. ... Gossip. ... Apologize without sincerity. ... Make you feel nervous....

Read More »
Do guys care if you have your nails done?
Do guys care if you have your nails done?

Well-groomed hands are a plus—men definitely notice dirty or untrimmed finger nails. Colored polish is even better because men find that burst of...

Read More »
How do you not get played by a guy?
How do you not get played by a guy?

10 Foolproof Ways To Stop Getting Played By Men Reinforce Your Foundations. ... Take Responsibility for the Role You Play. ... Meet More Men. ......

Read More »
What are the four types of faith?
What are the four types of faith?

Faith: Four Types of Faith, Which Do You Have? Dead Faith. James informs us that faith without works is dead (James 2:17). ... Demonic Faith. James...

Read More »