Difference between revisions of "ADD"

From GbdevWiki
Jump to: navigation, search
(New page: 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...)
 
 
(6 intermediate revisions by one other user not shown)
Line 1: Line 1:
 +
{{Opcode}}
 
ADD is an assembly opcode.
 
ADD is an assembly opcode.
  
= add a,reg8 =
+
== add a,reg8 ==
 
Adds the contents of an 8-bit register to the contents of accumulator and stores the result in accumulator.
 
Adds the contents of an 8-bit register to the contents of accumulator and stores the result in accumulator.
  
$80: add a,b
+
*$80: add a,b
$81: add a,c
+
*$81: add a,c
$82: add a,d
+
*$82: add a,d
$83: add a,e
+
*$83: add a,e
$84: add a,h
+
*$84: add a,h
$85: add a,l
+
*$85: add a,l
$86: add a,(hl)
+
*$86: add a,(hl)
$87: add a,a
+
*$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.
 +
 
 +
[[Category:Assembly_Opcodes]]

Latest revision as of 23:09, 5 March 2008

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.