BIT

From GbdevWiki
Revision as of 12:18, 25 May 2012 by Beannaich (Talk | contribs) (Created page with '{{Opcode}} This instruction is part of the $CB prefixed extended instruction set.<br> This instruction group tests various bits of the various registers, or memory location. It …')

(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

This instruction is part of the $CB prefixed extended instruction set.
This instruction group tests various bits of the various registers, or memory location. It is encoded as follows:

01bbbrrr
  | || |
  | |+-+- Register
  +-+---- Bit to test ('b' has a binary weight of 2^b)

Where register is one of the following:

000: B    - 2 Machine Cycles
001: C    - 2 Machine Cycles
010: D    - 2 Machine Cycles
011: E    - 2 Machine Cycles
100: H    - 2 Machine Cycles
101: L    - 2 Machine Cycles
110: (HL) - 3 Machine Cycles
111: A    - 2 Machine Cycles

Flags

Z: 1 if specified bit is 0; 0 otherwise
H: 1
N: 0
C: -