The ALU is only 8 bits wide so arithmetic operations can only be done with
the low byte of a register. A carry or borrow is propagated to the high order
- ADD Rx, Ry
Adds the low order byte of Ry to the low order byte of Rx. If a carry
occurs the high order byte of Rx will be incremented by one.
If the high byte is set to 0 before the ADD instruction a carry can easily
be detected by checking for a zero high byte.
- SUB Rx, Ry
Subtracts the low order byte of Ry from the low order byte of Rx. If a
borrow occurs the high byte of Rx will be decremented by one.
- ADDH Rx, Ry (ADDS1 Rx, Ry)
The low byte of Ry will be added to the high byte of Rx and the result
is stored in the low byte of Rx. If a carry occurs the high byte of Rx
will be set to 1 else to 0.
This instruction makes it possible e.g. to include the carries into
a series of calculation.
- ADDH2 Rx, Ry (ADDS2 Rx, Ry)
Like ADDH with the exception that the high byte will be set to 0 if
a carry/borrow occured, else it will be set to $FF. This is useful
to take care of borrows of previous SUBs.
- ADD Rx, #i (ADDI Rx, DATA)
The 8-bit immediate value i (DATA+1) is added to Rx.
- SUB Rx, #i (SUBI Rx, DATA)
The 8-bit immediate value i (DATA+1) is subtracted from Rx.
- AND Rx, Ry
- OR Rx, Ry (ORB Rx, Ry)
- XOR Rx, Ry
Logical exclusive OR
- SET Rx, #%xxxxxxxx (SETI Rx, MASK)
Sets the bits in Rx to one which have a corresponding 1 bit in x. This
is the same as an OR instruction but with an immediate value instead.
- CLR Rx, #%xxxxxxxx (CLRI Rx, MASK)
Clears the bits in Rx which have a corresponding 1 bit in x.
- SHR Rx (SHFTR Ry, 1)
Shifts Rx one bit to the right. The MSB of the low byte is set to the
LSB of the high byte. The high byte itself remains unaltered.
- ROR Rx (ROTR Ry, D)
Rotates Rx one bit to the right. The LSB of the low byte becomes the MSB
of the low byte. The high byte remains unaltered.
- ROR3 Rx (ROTR Ry, E)
Like ROR but rotates three bits to the right.
- SWAP Rx (ROTR Ry, F)
Swaps the two nibbles (4 bits each) of the low byte. The high byte
In fact this instruction is a rotate by four bits.