Difference between revisions of "PM Opc SUB16"
From SublabWiki
(→Examples) |
m (→Examples) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== SUB = Subtraction (16-Bits) == | == SUB = Subtraction (16-Bits) == | ||
− | {| border="1" style="text-align:left" | + | {| border="1" style="text-align:left" class="sortable" |
!Hex | !Hex | ||
!Mnemonic | !Mnemonic | ||
Line 111: | Line 111: | ||
Overflow: Set when result overflow 16-bits signed range (< -32768 OR > 32767) | Overflow: Set when result overflow 16-bits signed range (< -32768 OR > 32767) | ||
− | Sign: Set when | + | Sign: Set when bit 15 of the result is 1 |
=== Examples === | === Examples === | ||
; BA = 0x2EF0 | ; BA = 0x2EF0 | ||
− | SUB BA, $1337 | + | '''SUB BA, $1337''' |
; BA = 0x1BB9 (0x2EF0 - 0x1337 = 0x(0)1BB9) | ; BA = 0x1BB9 (0x2EF0 - 0x1337 = 0x(0)1BB9) | ||
− | ; F = (Zero = 0):(Carry = 0):(Overflow=0):(Sign=0) | + | ; F = (Zero=0):(Carry=0):(Overflow=0):(Sign=0) |
; HL = 0xBB7E | ; HL = 0xBB7E | ||
; BA = 0xCF12 | ; BA = 0xCF12 | ||
− | SUB BA, HL | + | '''SUB BA, HL''' |
; HL = 0xBB7E | ; HL = 0xBB7E | ||
; BA = 0xEC6C (0xCF12 - 0xBB7E = 0x(1)EC6C) | ; BA = 0xEC6C (0xCF12 - 0xBB7E = 0x(1)EC6C) | ||
− | ; F = (Zero = 0):(Carry = 1):(Overflow=0):(Sign=1) | + | ; F = (Zero=0):(Carry=1):(Overflow=0):(Sign=1) |
[[PM_InstructionList|'''« Back to Instruction set''']] | [[PM_InstructionList|'''« Back to Instruction set''']] |
Latest revision as of 00:15, 21 April 2009
SUB = Subtraction (16-Bits)
Hex | Mnemonic | Cycles |
---|---|---|
D0 nn nn | SUB BA, #nnnn | 12 |
D1 nn nn | SUB HL, #nnnn | 12 |
D2 nn nn | SUB X, #nnnn | 12 |
D3 nn nn | SUB Y, #nnnn | 12 |
CF 6A nn nn | SUB SP, #nnnn | 16 |
CF 08 | SUB BA, BA | 16 |
CF 09 | SUB BA, HL | 16 |
CF 0A | SUB BA, X | 16 |
CF 0B | SUB BA, Y | 16 |
CF 28 | SUB HL, BA | 16 |
CF 29 | SUB HL, HL | 16 |
CF 2A | SUB HL, X | 16 |
CF 2B | SUB HL, Y | 16 |
CF 48 | SUB X, BA | 16 |
CF 49 | SUB X, HL | 16 |
CF 4A | SUB Y, BA | 16 |
CF 4B | SUB Y, HL | 16 |
CF 4C | SUB SP, BA | 16 |
CF 4D | SUB SP, HL | 16 |
Execute
#nnnn = Immediate unsigned 16-Bits BA = Register BA: (B shl 8) or A HL = Register HL: (H shl 8) or L X = Register X Y = Register Y SP = Register SP (Stack Pointer)
; SUB Ds, Sc ; ; Ds = Destination ; Sc = Source Ds = Ds - Sc
Description
16-Bits Source subtracts to the 16-Bits Destination.
Conditions
Zero: Set when result is 0
Carry: Set when result is < 0
Overflow: Set when result overflow 16-bits signed range (< -32768 OR > 32767)
Sign: Set when bit 15 of the result is 1
Examples
; BA = 0x2EF0 SUB BA, $1337 ; BA = 0x1BB9 (0x2EF0 - 0x1337 = 0x(0)1BB9) ; F = (Zero=0):(Carry=0):(Overflow=0):(Sign=0)
; HL = 0xBB7E ; BA = 0xCF12 SUB BA, HL ; HL = 0xBB7E ; BA = 0xEC6C (0xCF12 - 0xBB7E = 0x(1)EC6C) ; F = (Zero=0):(Carry=1):(Overflow=0):(Sign=1)