ADD

From GbdevWiki
Revision as of 22:09, 5 March 2008 by Nitro2k01 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This is an article about the GB-Z80 CPU.

Opcodes:

Arithmetic and logical: ADD - ADD (16-bit) including LD HL,SP+nn - ADC - AND - CP - CPL - DAA - DEC - DEC and INC (16-bit) - INC - SBC - SUB - OR - XOR
Conditional: CALL - JP - JR - RET
Load: LD (8-bit) - LD (16-bit)
Extended Set: BIT - RES - RL - RLC - RR - RRC - SET - SLA - SRA - SRL - SWAP

ADD is an assembly opcode.

add a,reg8

Adds the contents of an 8-bit register to the contents of accumulator and stores the result in accumulator.

  • $80: add a,b
  • $81: add a,c
  • $82: add a,d
  • $83: add a,e
  • $84: add a,h
  • $85: add a,l
  • $86: add a,(hl)
  • $87: add a,a
  • $C6 $XX: add a,$XX

Returns:

  • Z - Set if result is zero.
  • N - Reset.
  • H - Set if carry from bit 3.
  • C - Set if carry from bit 7.

add hl,reg16

Adds the contents of a 16-bit register to the contents of hl and stores the result in hl.

  • $09: add hl,bc
  • $19: add hl,de
  • $29: add hl,hl
  • $39: add hl,sp

Returns:

  • Z - Unaffected.
  • N - Reset.
  • H - Set if carry from bit 11.
  • C - Set if carry from bit 15.

add sp,2comp

Adds an 8-bit 2's complement value to sp and stores the result in sp.

  • $E8: add sp,2comp

Returns:

  • Z - Reset.
  • N - Reset.
  • H - Set or reset according to operation.
  • C - Set or reset according to operation.