English
Language : 

S912XEG384J3VA Datasheet, PDF (453/1324 Pages) Freescale Semiconductor, Inc – MC9S12XEP100 Reference Manual Covers MC9S12XE Family
SUB
Subtract without Carry
Chapter 10 XGATE (S12XGATEV3)
SUB
Operation
RS1 – RS2 ⇒ RD
RD − IMM16 ⇒ RD (translates to SUBL RD, #IMM16[7:0]; SUBH RD, #IMM16{15:8])
Subtracts two 16 bit values and stores the result in the destination register RD.
NOTE
When using immediate addressing mode (SUB RD, #IMM16), the V-flag
and the C-Flag of the first instruction (SUBL RD, #IMM16[7:0]) are not
considered by the second instruction (SUBH RD, #IMM16[15:8]).
⇒ Don’t rely on the V-Flag if RD - IMM16[7:0] < −215.
⇒ Don’t rely on the C-Flag if RD < IMM16[7:0].
CCR Effects
NZVC
∆∆∆∆
N: Set if bit 15 of the result is set; cleared otherwise.
Z: Set if the result is $0000; cleared otherwise.
V: Set if a two´s complement overflow resulted from the operation; cleared otherwise.
RS1[15] & RS2[15] & RD[15]new | RS1[15] & RS2[15] & RD[15]new
Refer to SUBH instruction for #IMM16 operations.
C: Set if there is a carry from the bit 15 of the result; cleared otherwise.
RS1[15] & RS2[15] | RS1[15] & RD[15]new | RS2[15] & RD[15]new
Refer to SUBH instruction for #IMM16 operations.
Code and CPU Cycles
Source Form
SUB RD, RS1, RS2
SUB RD, #IMM16
Address
Mode
TRI
IMM8
IMM8
00011
11000
11001
Machine Code
Cycles
RD
RS1
RS2 0 0
P
RD
IMM16[7:0]
P
RD
IMM16[15:8]
P
MC9S12XE-Family Reference Manual Rev. 1.25
Freescale Semiconductor
453