Operands: R a register of the current bank selected by the second byte, r any register, (mem) any memory operand (addressing modes),
# an immediate of the operation’s size, #3 a 3-bit number, #4 a bit number or count byte. Operation sizes are B (byte), W (word, 16 bits) and L (long, 32 bits); on a memory operand with no register to show the size
the assembler adds W to the mnemonic (ADDW (XIX),#$1234). Flags are listed in the order S Z H V N C: a letter means the flag is set from the result, 0 and 1 reset or set it,
- leaves it, P means V is the parity of the result, ? the manual leaves it undefined. Flag effects are those the decoder declares (our reading of the manual, checked against the RACE core: see the
differences). No cycle counts are given.
Load and store
| Mnemonic | Forms | Operation | Flags |
|---|---|---|---|
LD | LD R,# (one byte opcode $20+R, $30+R, $40+R); LD r,#; LD R,(mem); LD (mem),R; LD R,r, LD r,R; LD r,#3; LD (n8),# ($08); LD (mem),#8; LD (n16),(mem) and LD (mem),(n16) | Copies a byte, word or long. LD r,#3 loads a number 0 to 7. | - - - - - - |
LDW | LDW (n8),#16 ($0A); LDW (mem),#16 | Stores a word immediate to memory. | - - - - - - |
LDA | LDA R,(mem) with a word or a long R | Loads the address of the operand, not its contents. | - - - - - - |
LDAR | LDAR R,address (LDA R,(PC+d16)) | Loads a PC-relative address. | - - - - - - |
LDX | LDX (n8),#8: F7 00 n 00 d 00 | Stores a byte at an 8-bit address. | - - - - - - |
Stack
| Mnemonic | Forms | Operation | Flags |
|---|---|---|---|
PUSH | PUSH R (word $28+R, long $38+R), PUSH r, PUSH (mem), PUSH #8 ($09), PUSH A, PUSH F, PUSH SR | Decrements XSP by the size and stores the operand there. | - - - - - - |
PUSHW | PUSHW #16 ($0B), PUSHW (mem) | Pushes a word immediate or a word from memory. | - - - - - - |
POP | POP R (word $48+R, long $58+R), POP r, POP (mem), POP A, POP F, POP SR | Loads the operand from XSP and increments XSP. | POP F and POP SR load all six flags |
POPW | POPW (mem) | Pops a word to memory. | - - - - - - |
LINK | LINK r,d16 (long registers) | Pushes r, sets r to XSP, then adds the signed displacement to XSP (a stack frame). | - - - - - - |
UNLK | UNLK r | Sets XSP to r and pops r. | - - - - - - |
Exchange
| Mnemonic | Forms | Operation | Flags |
|---|---|---|---|
EX | EX R,r (byte, word), EX (mem),R (byte, word), EX F,F' | Swaps two operands; EX F,F' swaps the flag register with the alternate one. | EX F,F': all six; others none |
Block transfer and search
| Mnemonic | Forms | Operation | Flags |
|---|---|---|---|
LDI LDIW | LDI (XDE+),(XHL+) (83 10), LDI (XIX+),(XIY+) (85 10); word 93 10, 95 10 | Copies a byte (word), increments both pointers, decrements BC. | - - 0 V 0 - (V: BC not zero) |
LDIR LDIRW | as above, second byte $11 | Repeats LDI until BC is zero. | - - 0 0 0 - |
LDD LDDW | second byte $12 | Like LDI with both pointers decremented. | - - 0 V 0 - |
LDDR LDDRW | second byte $13 | Repeats LDD until BC is zero. | - - 0 0 0 - |
CPI | CPI A,(R+) (80+R 14), CPI WA,(R+) (90+R 14) | Compares A (WA) with memory, increments the pointer, decrements BC. | S Z H V 1 - (V: BC not zero) |
CPIR | second byte $15 | Repeats until BC is zero or the values are equal. | S Z H V 1 - |
CPD | second byte $16 | Like CPI with the pointer decremented. | S Z H V 1 - |
CPDR | second byte $17 | Repeats CPD. | S Z H V 1 - |
Arithmetic
| Mnemonic | Forms | Operation | Flags |
|---|---|---|---|
ADD ADDW | ADD R,r, ADD R,(mem), ADD (mem),R, ADD r,#, ADD (mem),# | Adds, byte, word or long. | S Z H V 0 C |
ADC ADCW | same forms | Adds with carry. | S Z H V 0 C |
SUB SUBW | same forms | Subtracts. | S Z H V 1 C |
SBC SBCW | same forms | Subtracts with borrow. | S Z H V 1 C |
CP CPW | same forms and CP r,#3 (byte, word) | Compares: subtracts and discards the result. | S Z H V 1 C |
INC INCW | INC #3,r, INC #3,(mem) | Adds 1 to 8 (0 means 8). | byte: S Z H V 0 -; word, long: none |
DEC DECW | DEC #3,r, DEC #3,(mem) | Subtracts 1 to 8. | byte: S Z H V 1 -; word, long: none |
NEG | NEG r (byte, word) | Two’s complement. | S Z H V 1 C |
CPL | CPL r (byte, word) | One’s complement. | - - 1 - 1 - |
DAA | DAA r (byte) | Decimal adjust after BCD arithmetic. | S Z H P - C |
EXTZ | EXTZ r (word, long) | Zero-extends the lower half into the whole register. | - - - - - - |
EXTS | EXTS r | Sign-extends the lower half. | - - - - - - |
PAA | PAA r | Adds one if the register is odd (pointer alignment). | - - - - - - |
MINC1 MINC2 MINC4 | MINC1 #16,r (word) | Modulo increment by 1, 2 or 4: adds the step, but subtracts the mask value instead when the register has reached it (a ring buffer pointer). | - - - - - - |
MDEC1 MDEC2 MDEC4 | MDEC1 #16,r | Modulo decrement. | - - - - - - |
Logic
| Mnemonic | Forms | Operation | Flags |
|---|---|---|---|
AND ANDW | AND R,r, AND R,(mem), AND (mem),R, AND r,#, AND (mem),# | Bitwise and. | S Z 1 P 0 0 |
OR ORW | same forms | Bitwise or. | S Z 0 P 0 0 |
XOR XORW | same forms | Bitwise exclusive or. | S Z 0 P 0 0 |
Multiply and divide
| Mnemonic | Forms | Operation | Flags |
|---|---|---|---|
MUL | MUL RR,r, MUL RR,(mem), MUL rr,# | Unsigned multiply: byte × byte gives a word, word × word a long. RR is the double-width register (WA for byte operations with R of W or A, XWA for words). | - - - - - - |
MULS | same forms | Signed multiply. | - - - - - - |
DIV | same forms | Unsigned divide of the double-width register: quotient in the lower half, remainder in the upper half. | - - - V - - |
DIVS | same forms | Signed divide. | - - - V - - |
MULA | MULA rr (word register code) | Multiply and add: adds the signed product of the words at (XDE) and (XHL) to the long register, then subtracts 2 from XHL. | S Z - V - - |
Bit operations
| Mnemonic | Forms | Operation | Flags |
|---|---|---|---|
BIT | BIT #4,r (byte, word), BIT #3,(mem) | Tests a bit: Z is set when it is clear. | ? Z 1 ? 0 - |
TSET | TSET #4,r, TSET #3,(mem) | Tests a bit as BIT does, then sets it. | ? Z 1 ? 0 - |
RES | RES #4,r, RES #3,(mem) | Clears a bit. | - - - - - - |
SET | SET #4,r, SET #3,(mem) | Sets a bit. | - - - - - - |
CHG | CHG #4,r, CHG #3,(mem) | Inverts a bit. | - - - - - - |
BS1F | BS1F A,r (word) | A = the number of the lowest set bit of r; V is set when r is zero. | - - - V - - |
BS1B | BS1B A,r | A = the number of the highest set bit. | - - - V - - |
MIRR | MIRR r (word) | Reverses the order of the 16 bits. | - - - - - - |
Rotate and shift
| Mnemonic | Forms | Operation | Flags |
|---|---|---|---|
RLC RLCW | RLC #4,r, RLC A,r, RLC (mem) | Rotates left (circular, the bit that leaves also goes to C). The count is a byte after the second byte (0 means 16), A, or 1 for a memory operand. | S Z 0 P 0 C |
RRC RRCW | same forms | Rotates right. | S Z 0 P 0 C |
RL RLW | same forms | Rotates left through the carry. | S Z 0 P 0 C |
RR RRW | same forms | Rotates right through the carry. | S Z 0 P 0 C |
SLA SLAW | same forms | Arithmetic shift left. | S Z 0 P 0 C |
SRA SRAW | same forms | Arithmetic shift right. | S Z 0 P 0 C |
SLL SLLW | same forms | Logical shift left. | S Z 0 P 0 C |
SRL SRLW | same forms | Logical shift right. | S Z 0 P 0 C |
RLD | RLD A,(mem) | Rotates the two nibbles of the byte at the operand left through the low nibble of A. | S Z 0 P 0 - |
RRD | RRD A,(mem) | The same to the right. | S Z 0 P 0 - |
Jump, call and return
| Mnemonic | Forms | Operation | Flags |
|---|---|---|---|
JP | JP #16 ($1A), JP #24 ($1B), JP cc,(mem) | Jumps. The viewer writes the target address; cc is left out for T. | - - - - - - |
JR | JR cc,addr ($60+cc, signed 8-bit displacement from the end of the instruction) | Conditional short branch. | - - - - - - |
JRL | JRL cc,addr ($70+cc, 16-bit displacement) | Conditional long branch. | - - - - - - |
CALL | CALL #16 ($1C), CALL #24 ($1D), CALL cc,(mem) | Pushes the address of the next instruction (a long) and jumps. | - - - - - - |
CALR | CALR addr ($1E, 16-bit displacement) | A relative call. | - - - - - - |
RET | RET ($0E), RET cc (B0 F0+cc) | Pops the return address. | - - - - - - |
RETD | RETD d16 ($0F) | Returns and adds the displacement to XSP (removes the arguments). | - - - - - - |
RETI | RETI ($07) | Returns from an interrupt: pops SR, then PC. | all six |
DJNZ | DJNZ r,addr (byte, word register) | Decrements r and branches when it is not zero. | - - - - - - |
Carry flag operations
| Mnemonic | Forms | Operation | Flags |
|---|---|---|---|
RCF | $10 | Resets C. | - - 0 - 0 0 |
SCF | $11 | Sets C. | - - 0 - 0 1 |
CCF | $12 | Inverts C. | - - ? - 0 C |
ZCF | $13 | Copies the inverse of Z to C. | - - ? - 0 C |
ANDCF | ANDCF #4,r, ANDCF A,r, ANDCF #3,(mem), ANDCF A,(mem) | C = C and a bit of the operand (the bit number is a number or the low bits of A). | - - - - - C |
ORCF | same forms | C = C or the bit. | - - - - - C |
XORCF | same forms | C = C xor the bit. | - - - - - C |
LDCF | same forms | C = the bit. | - - - - - C |
STCF | same forms | Stores C into the bit. | - - - - - - |
CPU control
| Mnemonic | Forms | Operation | Flags |
|---|---|---|---|
NOP | $00 | No operation. | - - - - - - |
NORMAL | $01 | Clears the MAX bit of SR. | - - - - - - |
MAX | $04 | Sets the MAX bit of SR. | - - - - - - |
HALT | $05 | Stops the CPU until an interrupt. | - - - - - - |
EI | EI #3 ($06 n) | Loads the interrupt mask level. EI 7 masks every maskable interrupt and is written DI by the assembler. | - - - - - - |
INCF | $0C | Adds 1 to the register file pointer RFP. | - - - - - - |
DECF | $0D | Subtracts 1 from RFP. | - - - - - - |
LDF | LDF #3 ($17 n) | Loads RFP. | - - - - - - |
SCC | SCC cc,r (byte, word) | Sets r to 1 when the condition is true, otherwise 0. | - - - - - - |
SWI | SWI n ($F8+n) | A software interrupt through the vector of number n. | all six (SR is pushed) |
LDC | LDC cr,r, LDC r,cr | Moves a register to or from a control register (the DMA registers: list). | - - - - - - |
Not described
- Cycle counts for every instruction (no source was read).
- The double-width register choice of
MUL RR,rfor the odd and even codes of a byte pair, which the viewer takes from the RACE core (WandAboth giveWA). - The flag effects of the word and long forms of the shifts and of
BS1F,BS1BandMULAbeyond what the RACE core does. - The interrupt entry sequence behind
SWIand the stack frameRETIrestores.