Jameco Electronics 2000, 3000 manual test for

Models: 3000 2000

1 349
Download 349 pages 5.72 Kb
Page 51
Image 51
;test for

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. In the following examples, the pseudo-code in the form LD DE,(65535-B)does not indicate a load of DE with the address pointed to by 65535-B, but simply indicates the difference between 65535 and the 16-bit unsigned integer B.

;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 (0x80 to 0x7F). Signed 16-bit integers span the range –32768 to + 32767 (0x8000 to 0x7FFF). 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.

42

Rabbit 3000 Microprocessor

Page 51
Image 51
Jameco Electronics 2000, 3000 manual test for