From 457b2d573299ef727e136cb1438987868a5b7bcc Mon Sep 17 00:00:00 2001 From: Rangi Date: Thu, 11 Dec 2025 16:44:28 -0500 Subject: [PATCH 1/2] Clarify usage versus encoding of `jr` and `ldh` --- man/gbz80.7 | 44 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/man/gbz80.7 b/man/gbz80.7 index 13bb7e29d..f3a7b831a 100644 --- a/man/gbz80.7 +++ b/man/gbz80.7 @@ -861,11 +861,13 @@ Flags: None affected. Relative Jump to address .Ar n16 . .Pp -The address is encoded as a signed 8-bit offset from the address immediately following the -.Ic JR -instruction, so the target address +The target address .Ar n16 -must be between +is +.Em encoded +as a signed 8-bit offset from the address immediately following the +.Ic JR +instruction, so it must be between .Sy -128 and .Sy 127 @@ -889,6 +891,18 @@ if condition .Ar cc is met. .Pp +The target address +.Ar n16 +is +.Em encoded +as a signed 8-bit offset from the address immediately following the +.Ic JR +instruction, so it must be between +.Sy -128 +and +.Sy 127 +bytes away. +.Pp Cycles: 3 taken / 2 untaken .Pp Bytes: 2 @@ -992,8 +1006,15 @@ Flags: None affected. Copy the value in register .Sy A into the byte at address -.Ar n16 , -provided the address is between +.Ar n16 . +.Pp +The destination address +.Ar n16 +is +.Em encoded +as its 8-bit low byte and assumes a high byte of +.Ad $FF , +so it must be between .Ad $FF00 and .Ad $FFFF . @@ -1043,8 +1064,15 @@ Flags: None affected. Copy the byte at address .Ar n16 into register -.Sy A , -provided the address is between +.Sy A . +.Pp +The source address +.Ar n16 +is +.Em encoded +as its 8-bit low byte and assumes a high byte of +.Ad $FF , +so it must be between .Ad $FF00 and .Ad $FFFF . From e9e8d03d61ae8a8b9b77eb7ee86e133922e9e77b Mon Sep 17 00:00:00 2001 From: Rangi Date: Thu, 11 Dec 2025 17:10:36 -0500 Subject: [PATCH 2/2] Add a line at the top contrasting with the GBDev opcode table --- man/gbz80.7 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/man/gbz80.7 b/man/gbz80.7 index f3a7b831a..5897aeada 100644 --- a/man/gbz80.7 +++ b/man/gbz80.7 @@ -11,6 +11,11 @@ This is the list of instructions supported by .Xr rgbasm 1 , including a short description, the number of bytes needed to encode them and the number of CPU cycles at 1MHz (or 2MHz in GBC double speed mode) needed to complete them. .Pp +Instructons are documented according to the syntax accepted by +.Xr rgbasm 1 , +which does not always match one-to-one with the way instructions are +.Lk encoded https://gbdev.io/gb-opcodes/optables/ . +.Pp Note: All arithmetic and logic instructions that use register .Sy A as a destination can omit the destination, since it is assumed to be register