Reputation: 301
I was looking through the MSP430's instruction set and stumbled upon something I can't quite understand. I can't seem to differentiate what the difference between JC
and JNZ
and JNC
and JEQ
. I understand the functions of JEQ
and JNZ
, but I'm a Little fuzzy on the usage of JC
and JNC
.
I know for a fact JC
and JNC
utilize the carry flag, but I'm not sure in what way it's used and how they differ from JNZ
and JEQ
.
Upvotes: 1
Views: 24596
Reputation: 676
JC = Jump if carry set (C=1)
JNC = Jump if carry is not set (C=0)
JZ = Jump if zero-flag is set
JNZ = Jump if zero-flag is not set
JEQ = Jump if equal => another 'name' for JZ
(There are many instruction aliases').
When you add two numbers with highest bit set, you'd end up with result with one bit longer that the original numbers. This new bit "goes" to carry. It's also used as borrow-flag in subtractions. Compare is the same as subtraction except that the result value is not stored.
That's what SBC does to the flags:
Status Bits N: Set if result is negative, reset if positive
Z: Set if result is zero, reset otherwise
C: Set if there is a carry from the MSB of the result, reset otherwise.
Set to 1 if no borrow, reset if borrow.
V: Set if an arithmetic overflow occurs, reset otherwise.
Upvotes: 4