GBZ80(7) | Miscellaneous Information Manual | GBZ80(7) |

`gbz80`

—
CPU opcode reference

Note: All arithmetic/logic operations that use register
**A** as destination can omit the destination as it is assumed
it's register **A**. The following two lines have the same
effect:

OR A,B OR B

`r8`- Any of the 8-bit registers (
**A**,**B**,**C**,**D**,**E**,**H**,**L**). `r16`- Any of the general-purpose 16-bit registers (
**BC**,**DE**,**HL**). `n8`- 8-bit integer constant.
`n16`- 16-bit integer constant.
`e8`- 8-bit offset (
`-`

**128**to**127**). `u3`- 3-bit unsigned integer constant (
**0**to**7**). `cc`- Condition codes:
**Z**:- Execute if Z is set.
**NZ**:- Execute if Z is not set.
**C**:- Execute if C is set.
**NC**:- Execute if C is not set.

`vec`- One of the
`RST`vectors (**0x00**,**0x08**,**0x10**,**0x18**,**0x20**,**0x28**,**0x30**and**0x38**).

Cycles: 1

Bytes: 1

Flags:

**Z**: Set if result is 0.**N**: 0**H**: Set if overflow from bit 3.**C**: Set if overflow from bit 7.

Cycles: 2

Bytes: 1

Flags: See ADC A,r8

Cycles: 2

Bytes: 2

Flags: See ADC A,r8

Cycles: 1

Bytes: 1

Flags:

**Z**: Set if result is 0.**N**: 0**H**: Set if overflow from bit 3.**C**: Set if overflow from bit 7.

Cycles: 2

Bytes: 1

Flags: See ADD A,r8

Cycles: 2

Bytes: 2

Flags: See ADD A,r8

Cycles: 2

Bytes: 1

Flags:

**N**: 0**H**: Set if overflow from bit 11.**C**: Set if overflow from bit 15.

Cycles: 2

Bytes: 1

Flags: See ADD HL,r16

Cycles: 4

Bytes: 2

Flags:

**Z**: 0**N**: 0**H**: Set if overflow from bit 3.**C**: Set if overflow from bit 7.

Cycles: 1

Bytes: 1

Flags:

**Z**: Set if result is 0.**N**: 0**H**: 1**C**: 0

Cycles: 2

Bytes: 1

Flags: See AND A,r8

Cycles: 2

Bytes: 2

Flags: See AND A,r8

Cycles: 2

Bytes: 2

Flags:

**Z**: Set if the selected bit is 0.**N**: 0**H**: 1

Cycles: 3

Bytes: 2

Flags: See BIT u3,r8

Cycles: 6

Bytes: 3

Flags: None affected.

Cycles: 6/3

Bytes: 3

Flags: None affected.

Cycles: 1

Bytes: 1

Flags:

**N**: 0**H**: 0**C**: Complemented.

Cycles: 1

Bytes: 1

Flags:

**Z**: Set if result is 0.**N**: 1**H**: Set if no borrow from bit 4.**C**: Set if no borrow (set if`r8`>**A**).

Cycles: 2

Bytes: 1

Flags: See CP A,r8

Cycles: 2

Bytes: 2

Flags: See CP A,r8

Cycles: 1

Bytes: 1

Flags:

**N**: 1**H**: 1

Cycles: 1

Bytes: 1

Flags:

**Z**: Set if result is 0.**H**: 0**C**: Set or reset depending on the operation.

Cycles: 1

Bytes: 1

Flags:

**Z**: Set if result is 0.**N**: 1**H**: Set if no borrow from bit 4.

Cycles: 3

Bytes: 1

Flags: See DEC r8

Cycles: 2

Bytes: 1

Flags: None affected.

Cycles: 2

Bytes: 1

Flags: None affected.

Cycles: 1

Bytes: 1

Flags: None affected.

Cycles: 1

Bytes: 1

Flags: None affected.

Cycles: -

Bytes: 1

Flags: None affected.

Cycles: 1

Bytes: 1

Flags:

**Z**: Set if result is 0.**N**: 0**H**: Set if overflow from bit 3.

Cycles: 3

Bytes: 1

Flags: See INC r8

Cycles: 2

Bytes: 1

Flags: None affected.

Cycles: 2

Bytes: 1

Flags: None affected.

Cycles: 4

Bytes: 3

Flags: None affected.

Cycles: 4/3

Bytes: 3

Flags: None affected.

Cycles: 1

Bytes: 1

Flags: None affected.

Cycles: 3

Bytes: 2

Flags: None affected.

Cycles: 3/2

Bytes: 2

Flags: None affected.

Cycles: 1

Bytes: 1

Flags: None affected.

Cycles: 2

Bytes: 2

Flags: None affected.

Cycles: 3

Bytes: 3

Flags: None affected.

Cycles: 2

Bytes: 1

Flags: None affected.

Cycles: 3

Bytes: 2

Flags: None affected.

Cycles: 2

Bytes: 1

Flags: None affected.

Cycles: 2

Bytes: 1

Flags: None affected.

Cycles: 4

Bytes: 3

Flags: None affected.

The following synonym forces this encoding: **LDH
[$FF00+n8],A**

Cycles: 3

Bytes: 2

Flags: None affected.

Cycles: 2

Bytes: 1

Flags: None affected.

Cycles: 2

Bytes: 1

Flags: None affected.

Cycles: 4

Bytes: 3

Flags: None affected.

The following synonym forces this encoding: **LDH
A,[$FF00+n8]**

Cycles: 3

Bytes: 2

Flags: None affected.

Cycles: 2

Bytes: 1

Flags: None affected.

Cycles: 2

Bytes: 1

Flags: None affected.

Cycles: 2

Bytes: 1

Flags: None affected.

Cycles: 2

Bytes: 1

Flags: None affected.

Cycles: 2

Bytes: 1

Flags: None affected.

Cycles: 3

Bytes: 3

Flags: None affected.

Cycles: 5

Bytes: 3

Flags: None affected.

Cycles: 3

Bytes: 2

Flags:

**Z**: 0**N**: 0**H**: Set if overflow from bit 3.**C**: Set if overflow from bit 7.

Cycles: 2

Bytes: 1

Flags: None affected.

Cycles: 1

Bytes: 1

Flags: None affected.

Cycles: 1

Bytes: 1

Flags:

**Z**: Set if result is 0.**N**: 0**H**: 0**C**: 0

Cycles: 2

Bytes: 1

Flags: See OR A,r8

Cycles: 2

Bytes: 2

Flags: See OR A,r8

Cycles: 3

Bytes: 1

Flags:

**Z**: Set from bit 7 of the popped low byte.**N**: Set from bit 6 of the popped low byte.**H**: Set from bit 5 of the popped low byte.**C**: Set from bit 4 of the popped low byte.

Cycles: 3

Bytes: 1

Flags: None affected.

Cycles: 4

Bytes: 1

Flags: None affected.

Cycles: 4

Bytes: 1

Flags: None affected.

Cycles: 2

Bytes: 2

Flags: None affected.

Cycles: 4

Bytes: 2

Flags: None affected.

Cycles: 4

Bytes: 1

Flags: None affected.

Cycles: 5/2

Bytes: 1

Flags: None affected.

Cycles: 4

Bytes: 1

Flags: None affected.

C <- [7 <- 0] <- C

Cycles: 2

Bytes: 2

Flags:

**Z**: Set if result is 0.**N**: 0**H**: 0**C**: Set according to result.

C <- [7 <- 0] <- C

Cycles: 4

Bytes: 2

Flags: See RL r8

C <- [7 <- 0] <- C

Cycles: 1

Bytes: 1

Flags:

**Z**: 0**N**: 0**H**: 0**C**: Set according to result.

C <- [7 <- 0] <- [7]

Cycles: 2

Bytes: 2

Flags:

**Z**: Set if result is 0.**N**: 0**H**: 0**C**: Set according to result.

C <- [7 <- 0] <- [7]

Cycles: 4

Bytes: 2

Flags: See RLC r8

C <- [7 <- 0] <- [7]

Cycles: 1

Bytes: 1

Flags:

**Z**: 0**N**: 0**H**: 0**C**: Set according to result.

C -> [7 -> 0] -> C

Cycles: 2

Bytes: 2

Flags:

**Z**: Set if result is 0.**N**: 0**H**: 0**C**: Set according to result.

C -> [7 -> 0] -> C

Cycles: 4

Bytes: 2

Flags: See RR r8

C -> [7 -> 0] -> C

Cycles: 1

Bytes: 1

Flags:

**Z**: 0**N**: 0**H**: 0**C**: Set according to result.

[0] -> [7 -> 0] -> C

Cycles: 2

Bytes: 2

Flags:

**Z**: Set if result is 0.**N**: 0**H**: 0**C**: Set according to result.

[0] -> [7 -> 0] -> C

Cycles: 4

Bytes: 2

Flags: See RRC r8

[0] -> [7 -> 0] -> C

Cycles: 1

Bytes: 1

Flags:

**Z**: 0**N**: 0**H**: 0**C**: Set according to result.

Cycles: 4

Bytes: 1

Flags: None affected.

Cycles: 1

Bytes: 1

Flags:

**Z**: Set if result is 0.**N**: 1**H**: Set if no borrow from bit 4.**C**: Set if no borrow (set if`r8`>**A**).

Cycles: 2

Bytes: 1

Flags: See SBC A,r8

Cycles: 2

Bytes: 2

Flags: See SBC A,r8

Cycles: 1

Bytes: 1

Flags:

**N**: 0**H**: 0**C**: 1

Cycles: 2

Bytes: 2

Flags: None affected.

Cycles: 4

Bytes: 2

Flags: None affected.

C <- [7 <- 0] <- 0

Cycles: 2

Bytes: 2

Flags:

**Z**: Set if result is 0.**N**: 0**H**: 0**C**: Set according to result.

C <- [7 <- 0] <- 0

Cycles: 4

Bytes: 2

Flags: See SLA r8

[7] -> [7 -> 0] -> C

Cycles: 2

Bytes: 2

Flags:

**Z**: Set if result is 0.**N**: 0**H**: 0**C**: Set according to result.

[7] -> [7 -> 0] -> C

Cycles: 4

Bytes: 2

Flags: See SRA r8

0 -> [7 -> 0] -> C

Cycles: 2

Bytes: 2

Flags:

**Z**: Set if result is 0.**N**: 0**H**: 0**C**: Set according to result.

0 -> [7 -> 0] -> C

Cycles: 4

Bytes: 2

Flags: See SRA r8

Cycles: -

Bytes: 2

Flags: None affected.

Cycles: 1

Bytes: 1

Flags:

**Z**: Set if result is 0.**N**: 1**H**: Set if no borrow from bit 4.**C**: Set if no borrow (set if`r8`>**A**).

Cycles: 2

Bytes: 1

Flags: See SUB A,r8

Cycles: 2

Bytes: 2

Flags: See SUB A,r8

Cycles: 2

Bytes: 2

Flags:

**Z**: Set if result is 0.**N**: 0**H**: 0**C**: 0

Cycles: 4

Bytes: 2

Flags: See SWAP r8

Cycles: 1

Bytes: 1

Flags:

**Z**: Set if result is 0.**N**: 0**H**: 0**C**: 0

Cycles: 2

Bytes: 1

Flags: See XOR A,r8

Cycles: 2

Bytes: 2

Flags: See XOR A,r8

`rgbds`

was originally written by Carsten Sørensen
as part of the ASMotor package, and was later packaged in RGBDS by Justin
Lloyd. It is now maintained by a number of contributors at
https://github.com/rednex/rgbds.
February 23, 2018 | RGBDS Manual |