shithub: rgbds

Download patch

ref: 4363ffcad480775e9cb9b546ac4b53975ed3a77c
parent: 14e6a79adce5216144e638f7f3c9ca66e79aa08e
author: Rangi <[email protected]>
date: Sun Aug 28 11:42:04 EDT 2022

Clarify the `JR` documentation based on its usage (#1032)

Fixes #1020

--- a/man/gbz80.7
+++ b/man/gbz80.7
@@ -171,8 +171,8 @@
 .It Sx JP HL
 .It Sx JP n16
 .It Sx JP cc,n16
-.It Sx JR e8
-.It Sx JR cc,e8
+.It Sx JR n16
+.It Sx JR cc,n16
 .It Sx RET cc
 .It Sx RET
 .It Sx RETI
@@ -754,12 +754,24 @@
 Bytes: 1
 .Pp
 Flags: None affected.
-.Ss JR e8
-Relative Jump by adding
-.Ar e8
-to the address of the instruction following the
-.Sy JR .
-To clarify, an operand of 0 is equivalent to no jumping.
+.Ss JR n16
+Relative Jump to address
+.Ar n16 .
+The address is encoded as a signed 8-bit offset from the address immediately following the
+.Ic JR
+instruction, so the target address
+.Ar n16
+must be between
+.Sy -128
+and
+.Sy 127
+bytes away.
+For example:
+.Bd -literal -offset indent
+    JR Label  ; no-op; encoded offset of 0
+Label:
+    JR Label  ; infinite loop; encoded offset of -2
+.Ed
 .Pp
 Cycles: 3
 .Pp
@@ -766,10 +778,10 @@
 Bytes: 2
 .Pp
 Flags: None affected.
-.Ss JR cc,e8
-Relative Jump by adding
-.Ar e8
-to the current address if condition
+.Ss JR cc,n16
+Relative Jump to address
+.Ar n16
+if condition
 .Ar cc
 is met.
 .Pp