Rabbit 2000 Microprocessor
User's Manual
PREV INDEX NEXT


18. Rabbit Instructions

Summary

All bugs related to instructions have been fixed in revisions A-C of the Rabbit 2000 chip. See Appendix B for more information.

Detailed information on instructions in provided in this chapter.

"Load Immediate Data" on page 178
"8-bit Indexed Load and Store" on page 178
"16-bit Indexed Loads and Stores" on page 178
"16-bit Load and Store 20-bit Address" on page 179
"Register to Register Moves" on page 179
"Exchange Instructions" on page 180
"Stack Manipulation Instructions" on page 180
"16-bit Arithmetic and Logical Ops" on page 180
"8-bit Arithmetic and Logical Ops" on page 181
"8-bit Bit Set, Reset and Test" on page 182
"8-bit Increment and Decrement" on page 182
"8-bit Fast A register Operations" on page 183
"8-bit Shifts and Rotates" on page 183
"Instruction Prefixes" on page 184
"Block Move Instructions" on page 184
"Control Instructions - Jumps and Calls" on page 185
"Miscellaneous Instructions" on page 185
"Privileged Instructions" on page 186
"Instructions in Alphabetical Order With Binary Encoding" on page 189

Spreadsheet Conventions
ALTD ("A" Column) Symbol Key
Flag Description
f
ALTD selects alternate flags
fr
ALTD selects alternate flags and register
r
ALTD selects alternate register
s
ALTD operation is a special case

IOI and IOE ("I" Column) Symbol Key
Flag Description
b
IOI and IOE affect source and destination
d
IOI and IOE affect destination
s
IOI and IOE affect source

Flag Register Key
S Z L/V 1 C Description
*
Sign flag affected
-
Sign flag not affected
*
Zero flag affected
-
Zero flag not affected
L
LV flag contains logical check result
V
LV flag contains arithmetic overflow result
0
LV flag is cleared
*
LV flag is affected
*
Carry flag is affected
-
Carry flag is not affected
0
Carry flag is cleared
1
Carry flag is set
1 The L/V (logical/overflow) flag serves a dual purpose--L/V is set to 1 for logical operations if any of the four most significant bits of the result are 1, and L/V is reset to 0 if all four of the most significant bits of the result are 0.


Symbols
Rabbit Z180 Meaning
b
b
Bit select:
000 = bit 0, 001 = bit 1,
010 = bit 2, 011 = bit 3,
100 = bit 4, 101 = bit 5,
110 = bit 6, 111 = bit 7
cc
cc
Condition code select:
00 = NZ, 01 = Z,
10 = NC, 11 = C
d
d
7-bit (signed) displacement. Expressed in two's complement.
dd
ww
Word register select destination: 00 = BC, 01 = DE, 10 = HL, 11 = SP
dd'
Word register select alternate: 00 = BC', 01 = DE', 10 = HL'
e
j
8-bit (signed) displacement added to PC.
f
f
Condition code select:
000 = NZ (non zero), 001 = Z (zero),
010 = NC (non carry), 011 = C (carry),
100 = LZ1 (logical zero), 101 = LO2 (logical one),
110 = P (sign plus), 111 = M (sign minus)
m
m
MSB of a 16-bit constant.
mn
mn
16-bit constant.
n
n
8-bit constant or LSB of a 16-bit constant.
r, g
g, g'
Byte register select:
000 = B, 001 = C,
010 = D, 011 = E,
100 = H, 101 = L,
111 = A
ss
ww
Word register select (source): 00 = BC, 01 = DE, 10 = HL, 11 = SP
v
v
Restart address select:
010 = 0x0020, 011 = 0x0030,
100 = 0x0040, 101 = 0x0050,
111 = 0x0070
xx
xx
Word register select: 00 = BC, 01 = DE, 10 = IX, 11 = SP
yy
yy
Word register select: 00 = BC, 01 = DE, 10 = IY, 11 = SP
zz
zz
Word register select: 00 = BC, 01 = DE, 10 = HL, 11 = AF
1 Logical zero if all four of the most significant bits of the result are 0.

2 Logical one if any of the four most significant bits of the result are 1.


18.1 Load Immediate Data

18.2 Load & Store to Immediate Address

18.3 8-bit Indexed Load and Store

18.4 16-bit Indexed Loads and Stores

18.5 16-bit Load and Store 20-bit Address

Note that the LDP instructions wrap around on a 64K page boundary. Since the LDP instruction operates on two-byte values, the second byte will wrap around and be written at the start of the page if you try to read or write across a page boundary. Thus, if you fetch or store at address 0xn,0xFFFF, you will get the bytes located at 0xn,0xFFFF and 0xn,0x0000 instead of 0xn,0xFFFFand 0x(n+1),0x0000 as you might expect. Therefore, do not use LDP at any physical address ending in 0xFFFF.

18.6 Register to Register Moves

18.7 Exchange Instructions


18.8 Stack Manipulation Instructions

18.9 16-bit Arithmetic and Logical Ops

18.10 8-bit Arithmetic and Logical Ops

18.11 8-bit Bit Set, Reset and Test

18.12 8-bit Increment and Decrement

18.13 8-bit Fast A register Operations

18.14 8-bit Shifts and Rotates


18.15 Instruction Prefixes

18.16 Block Move Instructions

If any of the block move instructions are prefixed by an I/O prefix, the destination will be in the specified I/O space. Add 1 clock for each iteration for the prefix if the prefix is IOI (internal I/O). If the prefix is IOE, add 2 clocks plus the number of I/O wait states enabled. The V flag is set when BC transitions from 1 to 0. If the V flag is not set another step is performed for the repeating versions of the instructions. Interrupts can occur between different repeats, but not within an iteration equivalent to LDD or LDI. Return from the interrupt is to the first byte of the instruction which is the I/O prefix byte if there is one.

18.17 Control Instructions - Jumps and Calls

18.18 Miscellaneous Instructions

18.19 Privileged Instructions

The privileged instructions are described in this section. Privilege means that an interrupt cannot take place between the privileged instruction and the following instruction.

The three instructions below are privileged.

The instructions to load the stack are privileged so that they can be followed by an instruction to load the stack segment (SSEG) register without the danger of an interrupt taking place with and incorrect association between the stack pointer and the stack segment register. For example,

The following instructions are privileged.

The instructions to modify the IP register are privileged so that they can be followed by a return instructions that is guaranteed to execute before another interrupt takes place. This avoids the possibility of an ever-growing stack.

The instruction reti can be used to set both the return address and the IP in a single instruction. If preceded by a LD XPC, a complete jump or call to a computed address can be done with no possible interrupt.

The instruction LD XPC,A is privileged so that it can be followed by other code setting interrupt priority or program counter without an intervening interrupt.

The instruction bit B,(HL) is privileged to make it possible to implement a semaphore without disabling interrupts. The following sequence is used. A bit is a semaphore, and the first task to set the bit owns the semaphore and has a right to manipulate the resources associated with the semaphore.

The SET instruction has no effect on the flags. Since no interrupt takes place after the BIT instruction, if the flag is zero that means that the semaphore was not set when tested by the bit instruction and that the set instruction has set the semaphore. If an interrupt was allowed between the BIT and set instructions, another routine could set the semaphore and two routines could think that they both owned the semaphore.


Rabbit Semiconductor
www.rabbit.com
PREV INDEX NEXT