Difference between revisions of "Z80:Opcodes:JR"

From Learn @ Cemetech
Jump to navigationJump to search
(Initial automated import)
 
 
(One intermediate revision by the same user not shown)
Line 6: Line 6:
 
<!-- Syntax for this instruction -->
 
<!-- Syntax for this instruction -->
  
     JP NN ;unconditional jump
+
     JR NN ;unconditional jump
     JP cond.,NN ;conditional jump
+
     JR cond.,NN ;conditional jump
  
 
=== Allowed Instructions ===
 
=== Allowed Instructions ===
Line 14: Line 14:
  
 
     ;Constants
 
     ;Constants
     JP NN ;no contition
+
     JR NN ;no condition
 
     JR C,NN ;jumps if C is set
 
     JR C,NN ;jumps if C is set
 
     JR NC,NN ;jumps if C is reset
 
     JR NC,NN ;jumps if C is reset
Line 29: Line 29:
 
<!-- What the instruction can be used for -->
 
<!-- What the instruction can be used for -->
 
== T-States ==
 
== T-States ==
cc is condition: NZ, Z, NC, C, PO, PE, P, M
+
cc is condition: NZ, Z, NC, C (PO, PE, P, M are not available)
 
{| class="wikitable"
 
{| class="wikitable"
 
| X || 12  
 
| X || 12  

Latest revision as of 18:31, 19 March 2017

Relative jumps to the address. This means that it can only jump between 128 bytes ahead or behind. Can be conditional or unconditional. JR takes up one less byte than JP, but is also slower. Weigh the needs of the code at the time before choosing one over the other (speed vs. size).

Syntax

   JR NN			;unconditional jump
   JR cond.,NN		;conditional jump

Allowed Instructions

   ;Constants
   JR NN		;no condition
   JR C,NN		;jumps if C is set
   JR NC,NN		;jumps if C is reset
   JR Z,NN		;jumps if Z is set
   JR NZ,NN	;jumps if Z is reset

Effects

All flags preserved.

Uses

T-States

cc is condition: NZ, Z, NC, C (PO, PE, P, M are not available)

X 12
condition met condition not met
cc,X 12 7

See Also

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