1 zero hl in 4 clocks, 2 exchanges not directly implemented, 3 manipulation of boolean variables – Jameco Electronics Rabbit 3000 User Manual

Page 49

Advertising
background image

40

Rabbit 3000 Microprocessor

3.4 How to Do It in Assembly Language—Tips and Tricks

3.4.1 Zero HL in 4 Clocks

BOOL HL ; 2 clocks, clears carry, HL is 1 or 0

RR HL

; 2 clocks, 4 total - get rid of possible 1

This sequence requires four clocks compared to six clocks for LD HL,0.

3.4.2 Exchanges Not Directly Implemented

HL<->HL' - eight clocks

EX DE’,HL

; 2 clocks

EX DE’,HL’ ; 4 clocks

EX DE’,HL ; 2 clocks, 8 total

DE<->DE' - six clocks

EX DE’,HL ; 2 clocks

EX DE,HL ; 2 clocks

EX DE’,HL ; 2 clocks, 6 total

BC<->BC' - 12 clocks

EX DE’,HL ; 2 clocks

EX DE,HL’ ; 4

EX DE,HL ; 2

EXX ; 2

EX DE,HL ; 2

Move between IX, IY and DE, DE'

IX/IY->DE / DE->IX/IY

;IX, IX --> DE

EX DE,HL

LD HL,IX/IY / LD IX/IY,HL

EX DE,HL ; 8 clocks total

; DE --> IX/ IY

EX DE,HL

LD IX/IY,HL

EX DE,HL

; 8 clocks total

3.4.3 Manipulation of Boolean Variables

Logical operations involving HL when HL is a logical variable with a value of 1 or 0—
this is important for the C language where the least bit of a 16-bit integer is used to repre-
sent a logical result

Logical not operator—invert bit 0 of HL in four clocks (also works for IX, IY in eight
clocks)

DEC HL

; 1 goes to zero, zero goes to -1

BOOL HL ; -1 to 1, zero to zero. 4 clocks total

Logical

xor

operator—

xor HL,DE

when HL/DE are 1 or 0.

ADD HL,DE

RES 1,l ; 6 clocks total, clear bit 1 result of if 1+1=2

Advertising
This manual is related to the following products: