z80:Opcodes:JP

From Learn @ Cemetech
Jump to: navigation, search

Absolute jumps to the address. Can be conditional or unconditional. JP takes one more byte than JR, but is also slightly faster, so decide whether speed or size is more important before choosing JP or JR. JP (HL), JP (IX), and JP (IY) are unconditional and are the fastest jumps, and do not take more bytes than other jumps.

Syntax

   JP NN			;unconditional jump
   JP cond.,NN		;conditional jump
   JP (reg16)            ;HL, IX and IY only

Allowed Instructions

   ;Constants
   JP NN		;no condition
   JP C,NN		;jumps if C is set
   JP NC,NN		;jumps if C is reset
   JP Z,NN		;jumps if Z is set
   JP NZ,NN	;jumps if Z is reset
   JP M,NN		;jumps if S is set
   JP P,NN		;jumps if S is reset
   JP PE,NN	;jumps if P/V is set
   JP PO,NN	;jumps if P/V is reset
   
   ;HL points to address
   JP (HL)
   
   ;IX points to address
   JP (IX)
   
   ;IY points to address
   JP (IY)

Effects

All flags preserved.

Uses

T-States

cc is condition: NZ, Z, NC, C, PO, PE, P, M

XX 10
cc,XX 10
(hl) 4
(ix) 8
(iy) 8

See Also

BIT,CALL,CP,CPD,CPDR,CPI,CPIR,DJNZ,JR