User’s Manual
41
3.4.4 Comparisons of Integers
Unsigned integers may be compared by testing the zero and carry flags after a subtract
operation. The zero flag is set if the numbers are equal. With the
SBC
instruction the carry
cleared is set if the number subtracted is less than or equal to the number it is subtracted
from. 8-bit unsigned integers span the range 0–255. 16-bit unsigned integers span the
range 0–65535.
OR a
; clear carry
SBC HL,DE ; HL=A and DE=B
A>=B !C
A<B C
A==B Z
A>B !C & !Z
A<=B C v Z
If A is in HL and B is in DE, these operations can be performed as follows assuming that
the object is to set HL to 1 or 0 depending on whether the compare is true or false.
; compute HL<DE
; unsigned integers
; EX DE,HL ; uncomment for DE<HL
OR a ; clear carry
SBC HL,DE
; C set if HL<DE
SBC HL,HL
; HL-HL-C -- -1 if carry set
BOOL HL
; set to 1 if carry, else zero
; else result == 0
;unsigned integers
; compute HL>=DE or DE>=HL - check for !C
; EX DE,HL ; uncomment for DE<=HL
OR a ; clear carry
SBC HL,DE ; !C if HL>=DE
SBC HL,HL ; HL-HL-C - zero if no carry, -1 if C
INC HL
; 14 / 16 clocks total -if C after first SBC result 1,
; else 0
; 0 if C , 1 if !C
;
: compute HL==DE
OR a
; clear carry
SBC HL,DE ; zero is equal
BOOL HL ; force to zero, 1
DEC HL ; invert logic
BOOL HL
; 12 clocks total -logical not, 1 for inputs equal
;
Содержание Rabbit 2000
Страница 2: ...Rabbit 3000 Microprocessor User s Manual 019 0108 040731 O ...
Страница 9: ...Rabbit 3000 Microprocessor ...
Страница 29: ...20 Rabbit 3000 Microprocessor ...
Страница 64: ...User s Manual 55 5 PIN ASSIGNMENTS AND FUNCTIONS ...
Страница 79: ...70 Rabbit 3000 Microprocessor ...
Страница 80: ...User s Manual 71 6 RABBIT INTERNAL I O REGISTERS ...
Страница 123: ...114 Rabbit 3000 Microprocessor ...
Страница 137: ...128 Rabbit 3000 Microprocessor ...
Страница 157: ...148 Rabbit 3000 Microprocessor ...
Страница 207: ...198 Rabbit 3000 Microprocessor ...
Страница 249: ...240 Rabbit 3000 Microprocessor ...
Страница 255: ...246 Rabbit 3000 Microprocessor ...
Страница 277: ...268 Rabbit 3000 Microprocessor ...
Страница 343: ...334 Rabbit 3000 Microprocessor ...
Страница 345: ......