Subtract Without Borrow - Cypress PSoC DESIGNER ImageCraft M8C Manual

Assembly language guide
Table of Contents

Advertisement

M8C Instruction Set
4.33

Subtract without Borrow

Computes the difference of the two operands. The first operand's value is replaced by the computed
difference. If the difference is less than zero, the Carry Flag is set in the Flag register. If the differ-
ence is zero, the Zero Flag is set in the Flag register; otherwise, the Zero Flag is cleared.
Instructions
Mnemonic
SUB
A, expr
SUB
A, [expr]
SUB
A, [X+expr]
SUB
[expr], A
SUB
[X+expr], A
SUB
[expr], expr
SUB
[X+expr], expr
Conditional
Flags:
Example 1:
Example 2:
70
Argument
A
A K
A ram k  
A
A
A ram X
ram k  
ram k   A
ram X
+
k
ram X
ram k
ram k
1
ram X
+
k
1
CF
Set if treating the numbers as unsigned, the difference < 0; cleared other-
wise.
ZF
Set if the result is zero; cleared otherwise.
mov
A, 0
or
F, 0x04
sub
A, 12
mov
[0x39], 2
mov
[0x40], FFh
inc
[0x40]
sub
[0x39], 0
ImageCraft Assembly Language Guide, Document # 001-44475 Rev. *B
Operation
+
k
 A
+
k
 k
1
2
 k
ram X
+
k
1
2
;set accumulator to zero
;set carry flag
;accumulator value is now 0xF4
;initialize ram[0x39]=0x02
;initialize ram[0x40]=0xff
;ram[0x40]=0x00, CF=1
;ram[0x39]=0x02
SUB
Opcode
Cycles Bytes
0x11
4
2
0x12
6
2
0x13
7
2
0x14
7
2
0x15
8
2
0x16
9
3
0x17
10
3
[+] Feedback

Advertisement

Table of Contents
loading

Table of Contents