42
Rabbit 3000 Microprocessor
Some simplifications are possible if one of the unsigned numbers being compared is a
constant. Note that the carry has a reverse sense from
SBC
.
;test for HL>B B is constant
LD DE,(65535-B)
ADD HL,DE ; carry set if HL>B
SBC HL,HL ; HL-HL-C - result -1 if carry set, else zero
BOOL HL ; 14 total clocks - true if HL>B
; HL>=B B is constant not zero
LD DE,(65536-B)
ADD HL,DE
SBC HL,HL
BOOL HL
; 14 clocks
; HL>=B and B is zero
LD HL,1
; 6 clocks
; HL<B B is a constant, not zero (if B==0 always false)
LD DE,(65536-B)
ADD HL,DE ; not carry if HL<B
SBC HL,HL ; -1 if carry, else 0
INC HL ; 14 clocks --0 if carry, else 1 if no carry
;
; HL <= B B is constant not zero
LD DE,(65535-B)
ADD HL,DE ; ~C if HL<=B
CCF ; C if true
SBC HL,HL ; if C -1 else 0
INC HL ; 16 clocks -- 1 if true, else 0
;
; HL <= B B is zero - true if HL==0
BOOL HL
; result in HL
;
; HL==B and B is a constant not zero
LD DE,(65536-B)
ADD HL,DE ; zero if equal
BOOL HL
INC HL
RES 1,l ; 16 clocks
; HL==B and B==0
BOOL HL
INC HL
RES 1,l ; 8 clocks
For signed integers the conventional method to look at the zero flag, the minus flag and
the overflow flag. Signed 8-bit integers span the range –128 to +127 (80h to 7Fh). Signed
16-bit integers span the range –32768 to + 32767 (8000h to 7FFFh). The sign and zero
flag tell which is the larger number after the subtraction unless the overflow is set, in
which case the sign flag needs to be inverted in the logic, that is, it is wrong.
A>B (!S & !V & !Z) v (S & V)
A<B (S & !V) v (!S & V & !Z)
A==B
A>=B
A<=B
Содержание 3000
Страница 1: ...Rabbit 3000 Microprocessor User s Manual 019 0108 020426 A...
Страница 8: ...Rabbit 3000 Microprocessor...
Страница 28: ...20 Rabbit 3000 Microprocessor...
Страница 73: ...User s Manual 65 6 RABBIT INTERNAL I O REGISTERS...
Страница 122: ...114 Rabbit 3000 Microprocessor...
Страница 138: ...130 Rabbit 3000 Microprocessor...
Страница 150: ...142 Rabbit 3000 Microprocessor...
Страница 188: ...180 Rabbit 3000 Microprocessor...
Страница 208: ...200 Rabbit 3000 Microprocessor...
Страница 228: ...220 Rabbit 3000 Microprocessor...
Страница 232: ...224 Rabbit 3000 Microprocessor...
Страница 238: ...230 Rabbit 3000 Microprocessor...
Страница 260: ...252 Rabbit 3000 Microprocessor...
Страница 266: ......