Section
07 Part 04 – Unsigned Sets
(SCC, SHI, SLS, SCS) |
“The big artist keeps an eye on nature and steals her
tools." ~Thomas
Eakins |
Introduction
These four S## instructions set/clear the destination operand based on unsigned results, just like BCC, BHI, BLS and BCS.
The SCC
Instruction
SCC – Set on Carry Clear
The C (Carry) flag is tested, if true, the
destination
operand is cleared
(%00000000), if false, the destination operand is set (%11111111).
Example
This
instruction sets depending on the condition of the C flag, interestingly,
the C flag is usually clear when the result is “higher than or equal”. Here is the instruction, along with the CMP
instruction (For clarity's sake):
cmp.b #$20,d0 scc.b d1 |
We’ll pretend d0
contains 00000098, the CMP is byte, so the comparison
is 20 & 98.
·
98 is higher
than 20, the carry flag is cleared, so the
68k will set d1 as 000000FF.
Now let’s pretend d0
contains 0000001F. The comparison is 20 & 1F.
·
1F is not higher than or equal to 20, the carry flag is set, so the 68k will set d1 as 00000000.
You
can use the mnemonic SHS (Set on Higher than or Same) instead
of SCC if you wanted to. SHS is another
mnemonic for SCC to make it easier to remember one of its main purposes. The assembler will convert it to SCC when
assembling.
The SHI
Instruction
SHI – Set on HIgher than
If
the C and Z flags are both clear, the destination operand is set (%11111111). Otherwise, the destination operand is cleared (%00000000).
Examples
This
instruction is the polar opposite of SCS (SLO), it
uses the C and Z flags together to detect if
the result is higher than:
cmpi.w #$0020,d0 shi.b IsHigher |
We’ll
pretend d0 contains 00000020,
the CMP is word, so the comparison is 0020
& 0020.
Now
let’s pretend d0 contains 0000F492. The comparison is 0020 & F492.
The SLS
Instruction
SLS – Set on Lower than or
Same
If
the C and Z flags are both set, the destination operand is set (%11111111). Otherwise, the destination operand is cleared (%00000000).
Examples
This
instruction is the polar opposite of SCC (SHS):
cmpi.w #$0020,d0 sls.b d1 |
We’ll
pretend d0 contains 00009800,
the CMP is word, so the comparison is 0020
& 9800.
Now
let’s pretend d0 contains 00000001. The comparison is 0020 & 0001.
The SCS Instruction
SCS – Set on Carry Set
The C (Carry) flag is tested, if true, the
destination
operand is set (%11111111), if false, the destination operand is cleared (%00000000).
Example
This
is pretty much the opposite of SCC, the instruction sets depending on the condition
of the C flag, interestingly, the C flag is usually
set when the result is “lower than”.
Here is the instruction, along with the CMP instruction (For clarity's
sake):
cmp.b #$20,d0 scs.b d1 |
We’ll pretend d0
contains 00000098, the CMP is byte, so the comparison
is 20 & 98.
·
98 is higher
than 20, the carry flag is cleared, so the
68k will set d1 as 00000000.
Now let’s pretend d0
contains 0000001F. The comparison is 20 & 1F.
·
1F is not higher than or equal to 20, the carry flag is set, so the 68k will set d1 as 000000FF.
As
you can see, the reverse result occurs to SCC.
You can use the mnemonic SLO (Set on LOwer) instead of SCS if you wanted to. SLO is another mnemonic for SCS to make it easier to remember one of its main purposes. The assembler will convert it to SCS when assembling.
SHS &
SLO
SHS
and SLO are mnemonics that can be used in place of SCC and SCS (respectively),
but it must be noted that SHS & SCC are the same instruction, and SLO &
SCS are the same instruction. They are
simply different names to interpret the same overall function.
Other
Examples
You have seen these instructions all used in examples based on data registers, here are some other destination operands the instructions can work with:
st.b (a0) st.b (a0)+ st.b -(a0) st.b $00200000 |
Since these instructions are byte sized only, they will not work on address registers directly:
st.b a0 |