English
Language : 

45111 Datasheet, PDF (142/184 Pages) List of Unclassifed Manufacturers – 14-DAY MONEY BACK GUARANTEE
13 Appendix C: SX Instruction Set
SUB dest, src
Subtract src from dest
Command
1) SUB fr, W
2) SUB fr1, #literal
3) SUB fr1, fr2
Words
1
2
2
Cycles
1 (4)
2 (8)
2 (8)
Affects
fr, C, DC, Z
fr, W, C, DC, Z
fr, W, C, DC, Z
Coding
0000 101f ffff SUB fr, W
1100 kkkk kkkk MOV W, #lit
0000 101f ffff SUB fr, W
0010 000f ffff MOV W, fr
0000 101f ffff SUB fr, W
Operation: src is subtracted from dest. C will be cleared to 0 if an underflow occurred; otherwise, C will be set to 1.
DC will be cleared to 0 if an underflow occurred in the least-significant nibble. Z will be set to 1 if the
result was 0; otherwise, Z will be cleared to 0. The MOV W, fr-W command is similar to #1, except the
result is moved to W, and fr keeps its original contents. If CARRYX is specified, c is added to the result.
Insert an STC before the first Sub on a register to avoid strange results.
SUBB dest, src_bit
Subtract src_bit from dest
Command
1) SUBB fr, op.bit
1) SUBB fr, /op.bit
Words
2
2
Cycles
2 (8)
2 (8)
Affects
fr, Z
fr, Z
Coding
0110 bbbf ffff SNB op.bit
0000 111f ffff DEC fr
0111 bbbf ffff SB op.bit
0000 111f ffff DEC fr
Operation: Subtracts src_bit from dest. If dest was decremented, Z will be set if the result was zero; else, Z will be
cleared. This instruction is useful for subtracting the carry from the upper byte of a double-byte value
after the lower byte has been subtracted.
SWAP dest
Swap nibbles in dest
Command
1) SWAP fr
Words
1
Cycles
1 (4)
Affects
fr
Coding
0011 101f ffff SWAP fr
Operation: The high- and low-order nibbles of dest are swapped. The MOV W,<>fr command is similar to SWAP
fr, except the result is moved to W, and fr keeps its original contents.
Page 142 • SX-Key/Blitz Development System Manual 2.0 • Parallax, Inc.