Professional Documents
Culture Documents
05 Condition Codes PDF
05 Condition Codes PDF
05 Condition Codes PDF
Fig 2-4 from M68000 8-/16-/32-Bit Microprocessors User’s Manual [pdf, 184p; Motorola]
Status Register … system byte
Z - zero
= 1 if all bits in the operand or result are 0
V - overflow
= 1 if an out-of-range condition, i.e. overflow, occurs in
signed arithmetic
C - carry
= 1 if a carry is generated out of the most significant bit
during an arithmetic operation; if borrow generated during
subtract – indicates an overflow in unsigned arithmetic
C=X=
N=
Z=
V=
Binary Arithmetic + CCR
e.g. 0011 1010
-1110 0000
C=X=
N=
Z=
V=
Binary Arithmetic + CCR
e.g. 0110 1010
+0100 0000
C=X=
N=
Z=
V=
Using the Condition Codes
the machine does 2’s complement
arithmetic
the machine generates ALL the flags
the machine does not know if you are
doing signed or unsigned operations
you pick which flags are appropriate to
your operation
A language
is like a bar
Python bar
.
.
C bar
.
.
Assembly language bar
Valid flags for unsigned arithmetic
Carry
e.g. A – B
= 1 → result incorrect
→ can not be stored if C=0 A B
→ unsigned overflow if C=1 A B
= 0 → result correct