shithub: rgbds

Download patch

ref: 2f16e82cf71d041043e6b8fcd8c49a9cdfae97a7
parent: 7b54312d9727dd3566f97119fba0304d93dc760d
author: ISSOtm <[email protected]>
date: Sat Mar 14 20:12:54 EDT 2020

Improve PC offset management

Basically make it always point to the instruction's first byte.
This was the behavior all whom I asked to intuitively expected.

--- a/src/asm/asmy.y
+++ b/src/asm/asmy.y
@@ -648,7 +648,7 @@
 lines		: /* empty */
 		| lines {
 			nListCountEmpty = 0;
-			nPCOffset = 1;
+			nPCOffset = 0;
 		} line '\n' {
 			nLineNo++;
 			nTotalLines++;
@@ -738,9 +738,9 @@
 		| else
 		| endc
 		| export
-		| { nPCOffset = 0; } db
-		| { nPCOffset = 0; } dw
-		| { nPCOffset = 0; } dl
+		| db
+		| dw
+		| dl
 		| ds
 		| section
 		| rsreset
@@ -1365,31 +1365,31 @@
 ;
 
 
-cpu_command	: z80_adc
-		| z80_add
-		| z80_and
-		| z80_bit
-		| z80_call
+cpu_command	: { nPCOffset = 1; } z80_adc
+		| { nPCOffset = 1; } z80_add
+		| { nPCOffset = 1; } z80_and
+		| { nPCOffset = 1; } z80_bit
+		| { nPCOffset = 1; } z80_call
 		| z80_ccf
-		| z80_cp
+		| { nPCOffset = 1; } z80_cp
 		| z80_cpl
 		| z80_daa
-		| z80_dec
+		| { nPCOffset = 1; } z80_dec
 		| z80_di
 		| z80_ei
 		| z80_halt
 		| z80_inc
-		| z80_jp
-		| z80_jr
-		| z80_ld
+		| { nPCOffset = 1; } z80_jp
+		| { nPCOffset = 1; } z80_jr
+		| { nPCOffset = 1; } z80_ld
 		| z80_ldd
 		| z80_ldi
-		| z80_ldio
+		| { nPCOffset = 1; } z80_ldio
 		| z80_nop
-		| z80_or
+		| { nPCOffset = 1; } z80_or
 		| z80_pop
 		| z80_push
-		| z80_res
+		| { nPCOffset = 1; } z80_res
 		| z80_ret
 		| z80_reti
 		| z80_rl
@@ -1400,17 +1400,17 @@
 		| z80_rra
 		| z80_rrc
 		| z80_rrca
-		| z80_rst
-		| z80_sbc
+		| /*{ nPCOffset = 0; }*/ z80_rst
+		| { nPCOffset = 1; } z80_sbc
 		| z80_scf
-		| z80_set
+		| { nPCOffset = 1; } z80_set
 		| z80_sla
 		| z80_sra
 		| z80_srl
-		| z80_stop
-		| z80_sub
+		| { nPCOffset = 1; } z80_stop
+		| { nPCOffset = 1; } z80_sub
 		| z80_swap
-		| z80_xor
+		| { nPCOffset = 1; } z80_xor
 ;
 
 z80_adc		: T_Z80_ADC op_a_n {
--- /dev/null
+++ b/test/asm/pc-operand.asm
@@ -1,0 +1,13 @@
+SECTION "fixed", ROM0[0]
+
+	rst @    ; rst 0
+	ld de, @ ; ld de, 1
+	bit @, h ; bit 4, h
+	db @, @  ; db 6, 7
+
+SECTION "floating", ROM0
+
+	rst @    ; rst 8
+	ld l, @  ; ld l, 9
+	dw @, @  ; dw 11, 13
+	dl @, @  ; dl 15, 19
binary files /dev/null b/test/asm/pc-operand.out.bin differ