16-Bit Arithmetic Operation Instructions - Nintendo GAME BOY Programming Manual

Hide thumbs Also See for GAME BOY:
Table of Contents

Advertisement

2.4 16-Bit Arithmetic Operation Instructions

ADD
HL,
Adds the contents of register pair ss to the contents of register pair HL and stores the results in HL.
ss codes are as follows:
Flag
Z: No change
H: Set if there is a carry from bit 11; otherwise reset.
N: Rest
CY: Set if there is a carry from bit 15; otherwise reset.
Example: When HL = 8A23h, BC = 0605h,
ADD HL, BC ; HL ← 9028h, H ← 1, N ← 0, CY ← 0
ADD HL, HL ; HL ← 1446h, H ← 1, N ← 0, CY ← 1
ADD
SP,
Adds the contents of the 8-bit immediate operand e and SP and stores the results in SP.
Example: SP = FFF8h
ADD SP, 2 ; SP ← 0xFFFA, CY ← 0, H ← 0, N ← 0, Z ← 0
INC
ss
Increments the contents of register pair ss by 1.
Example: When DE = 235Fh,
INC DE ; DE ← 2360h
HL ← HL + ss
ss
Register Pair
BC
DE
HL
SP
SP ← SP + e
e
ss ← ss + 1
CY
H
*
*
0
ss
00
01
10
11
CY
H
*
*
0
CY
H
--
--
--
107
Chapter 4: CPU Instruction Set
N
Z
CYCL
7 6
5 4 3
--
2
00
ss1
N
Z
CYCL
7 6
5 4 3
0
4
11
101
N
Z
CYCL
7 6
5 4 3
--
2
00
ss0
2 1 0
001
2 1 0
000
e
2 1 0
011

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents