Motorola M68000 Betriebsanweisung Seite 75

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 256
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 74
Conditional and Arithmetic Instructions 61
The Overflow Bit
What if we were adding signed numbers? A carry out of the high-order
bit is not necessarily indicative of a result that is too large. Adding two
negative numbers will result in the carry bit being set. For example,
11111110 -2
+ l i m i i i -l
111111101 -3
A result that is too large can be detected when the sign bit (most signif
icant bit) changes when we dont want it to. This condition is known as
overflow. The overflow bit (V) is set or reset depending on the occur
rence of the overflow condition. V is affected by all arithmetic instruc
tions regardless of whether operands are treated as signed or unsigned
numbers. The 68000 instructions dont know the difference. Either V or
C must be used, for signed or unsigned arithmetic, respectively. The BVS
(branch on overflow set) and BVC (branch on overflow clear) instruc
tions are provided for signed arithmetic.
Subtraction also results in similar effects on C and V. If an unsigned
subtraction results in a borrow into the most significant bit position, the
carry bit is set. Since an unsigned subtraction cannot result in a negative
value, this is an error. The overflow bit is set for subtractions as well. If
we subtract a positive number from a negative number, and the result
is a negative number that is too large, V will be set. Overflow can also
result from subtracting a negative number from a positive number. If the
positive result is too large, V will be set.
The Zero and negative Bits
In addition to determining if the result of an arithmetic operation has
exceeded the size capacity of the destination, a programmer may also
desire to know if the result is positive, negative, or zero. The zero bit
(Z) and negative bit (N) are provided for these purposes. The zero bit
is set if the numerical result is zero. This means that all bits of the result
are zero. The BEQ (branch on equal) and BNE (branch on not equal)
instructions will conditionally branch depending on the value of Z.
A zero value can be used as a signal to exit an indefinite loop. The
following program outputs the integers from 10 to 1 in reverse order.
Seitenansicht 74
1 2 ... 70 71 72 73 74 75 76 77 78 79 80 ... 255 256

Kommentare zu diesen Handbüchern

Keine Kommentare