Mnemonics

SUB

8-bit Arithmetic Group
Expansion:
SUBtract
Usage:
sub {r|??}

Subtract a given value from register A.

Z80.CPU instructions
Instruction Description Opcode
SUB A Subtract A with itself 97
SUB B Subtract the 8-bit number in B register with value in A register 90
SUB C Subtract the 8-bit number in C register with value in A register 91
SUB D Subtract the 8-bit number in D register with value in A register 92
SUB E Subtract the 8-bit number in E register with value in A register 93
SUB H Subtract the 8-bit number in H register with value in A register 94
SUB L Subtract the 8-bit number in L register with value in A register 95
SUB {??} Subtract the 8-bit immediate number with value in A register D6 {??}
SUB (HL) Subtract the 8-bit number at memory address HL with value in A register 96
SUB (IX+displacement) Subtract the 8-bit value in IX with value in A register DD96 ??
SUB (IY+displacement) Subtract the 8-bit value in IY with value in A register FD96 ??

Example

; Example ld a, 10 ; load the value 10 into register a sub 4 ; subtract 4 from a ; a = 6

Example 2

; Example ld a, 15 ; load the value 15 into register a ld b ; Load the value 7 into register b sub b ; subtract the value in b from a ; a = 8

See also