Arithmetic and Logic Instructions

http://www.asm86.cwc.net/

by Ciaran McCreesh
Created: 14th November 1999
Last Modified: 14th November 1999

8 Bit Arithmetic

Mnemonic Bytes T-States Description
add a,r 1 4 Adds a to r and stores the result in a
add a,n 2 7 Adds a to n and stores the result in a
add a,(hl) 1 7 Adds a to (hl) and stores the result in a
add a,(ii + d) 3 19 Adds a to (ii + d) and stores the result in a
adc a,r 1 4 Adds a and the carry flag to r and stores the result in a
adc a,n 2 7 Adds a and the carry flag to n and stores the result in a
adc a,(hl) 1 7 Adds a and the carry flag to (hl) and stores the result in a
adc a,(ii + d) 3 19 Adds a and the carry flag to (ii + d) and stores the result in a
sub r 1 4 Subtracts r from a and stores the result in a
sub n 2 7 Subtracts n from a and stores the result in a
sub (hl) 1 7 Subtracts (hl) from a and stores the result in a
sub (ii + d) 3 19 Subtracts (ii + d) from a and stores the result in a
sbc a,r 1 4 Subtracts r and the value of the carry flag from a and stores the result in a
sbc a,n 2 7 Subtracts n and the value of the carry flag from a and stores the result in a
sbc a,(hl) 1 7 Subtracts (hl) and the value of the carry flag from a and stores the result in a
sbc a,(ii + d) 3 19 Subtracts (ii + d) and the value of the carry flag from a and stores the result in a
inc r 1 4 Adds 1 to r
inc (hl) 1 11 Adds 1 to (hl)
inc (ii + d) 3 23 Adds 1 to (ii + d)
dec r 1 4 Subtracts 1 from r
dec (hl) 1 11 Subtracts 1 from (hl)
dec (ii + d) 3 23 Subtracts 1 from (ii + d)
cp r 1 4 Subtracts r from a and stores the result nowhere
cp n 2 7 Subtracts n from a and stores the result nowhere
cp (hl) 1 7 Subtracts (hl) from a and stores the result nowhere
cp (ii + d) 3 19 Subtracts (ii + d) from a and stores the result nowhere

16 Bit Arithmetic

Mnemonic Bytes T-States Description
add hl,dd 1 11 Adds hl to dd and stores the result in hl
adc hl,dd 2 15 Adds hl and the value of the carry flag to dd and stores the result in hl
sbc hl,dd 2 15 Subtracts dd from hl and stores the result in hl
add ix,pp 2 15 Adds ix to pp and stores the result in ix
add iy,rr 2 15 Adds iy to rr and stores the result in iy
inc dd 1 6 Adds 1 to dd
inc ii 2 10 Adds 1 to ii
dec dd 1 6 Subtracts 1 from dd
dec ii 2 10 Subtracts 1 from ii

Logic Instructions

Mnemonic Bytes T-States Description
and r 1 4 Performs a binary and operation on a and r and stores the result in a
and n 2 7 Performs a binary and operation on a and n and stores the result in a
and (hl) 1 7 Performs a binary and operation on a and (hl) and stores the result in a
and (ii + d) 3 19 Performs a binary and operation on a and (ii + d) and stores the result in a
or r 1 4 Performs a binary or operation on a and r and stores the result in a
or n 2 7 Performs a binary or operation on a and n and stores the result in a
or (hl) 1 7 Performs a binary or operation on a and (hl) and stores the result in a
or (ii + d) 3 19 Performs a binary or operation on a and (ii + d) and stores the result in a
xor r 1 4 Performs a binary exclusive-or operation on a and r and stores the result in a
xor n 2 7 Performs a binary exclusive-or operation on a and n and stores the result in a
xor (hl) 1 7 Performs a binary exclusive-or operation on a and (hl) and stores the result in a
xor (ii + d) 3 19 Performs a binary exclusive-or operation on a and (ii + d) and stores the result in a
cpl 1 4 Stores the one's complement of a in a
neg 2 8 Stores the two's complement of a in a