Test and jump instructions
The IBM 51x0 processor doesn't have a status register like most other
microprocessors that stores different flags reflecting the status of a
previous operation. So there are no conditional jumps that could test
e.g. the zero flag or the overflow flag. And there can't be any instruction
that explicitly modifies the flags.
Instead this processor implements a combination of test and skip instructions
that compare one or two registers and then decides whether to skip the
following instruction or not.
The different skip instructions
Note: All compares are done with the low order byte of the registers except
where stated otherwise.
- SLE Rx, Ry - Skip if Less or Equal
Skips the following instruction if Rx <= Ry.
LBI R1, #2
LBI R2, #5
SLE R1, R2 ; The HALT instruction will be skipped
- SLT, SE, SGT, SGE, SNE
Like SLE but for <, =, >, >= and <>.
- SZ Rx - Skip if Zero
SNZ Rx - Skip if Not Zero
Skips the following instruction if Rx = $00 resp. <> $00.
- SS Rx - Skip if all bits Set
SNS Rx - Skip if Not all bits Set
Skips is all bits in Rx are set, e.g. Rx = $FF respectively if not
all bits are set (Rx <> $FF).
- SBS Rx, Ry - Skip if complete Bitmask Set
SNBS Rx, Ry - Skip if Not complete Bitmask Set
The first instructions skips if all set bits in Ry are set in Rx, too. It
does a logical and of the two operands and looks if the result is equal to
The second instruction is the counterpart of the first one, i.e. it skips
if not all set bits in Ry are set in Rx, too.
- SBSH Rx, Ry - Skip if Bit Set (High-byte)
SNBSH Rx, Ry - Skip if Not Bit Set (High-byte)
Like SBS and SNBS but the mask in Ry is compared to the high byte of Rx
instead of the low byte.
- SBC Rx, Ry - Skip if complete Bitmask Cleared
SNBC Rx, Ry - Skip if Not complete Bitmask Cleared
These two instructions are the inverse of SBS and SNBS. Instead of
comparing set bits in Rx, all set bits in Ry are matched against cleared
bits in Rx, i.e. the result of the logical and has to be zero (resp.
unequal to zero).
All this is quite confusing, so here are some examples:
LBI R1, #%11010110
LBI R2, #%01000110
LBI R3, #%00100001
LBI R4, #%01100011
SBS R1, R2 -> skip
SBS R1, R3 -> no skip
SNBS R1, R3 -> skip
SNBS R1, R4 -> skip
SNBC R1, R3 -> no skip
SNBC R1, R4 -> skip
SBC R1, R3 -> skip