diff --git a/src/asm/parser.y b/src/asm/parser.y index 31d7feab..b9351524 100644 --- a/src/asm/parser.y +++ b/src/asm/parser.y @@ -487,6 +487,7 @@ enum { %type const_3bit %type reloc_8bit %type reloc_8bit_no_str +%type reloc_8bit_offset %type reloc_16bit %type reloc_16bit_no_str %type sectiontype @@ -1344,6 +1345,16 @@ reloc_8bit_no_str : relocexpr_no_str { } ; +reloc_8bit_offset : T_OP_ADD relocexpr { + rpn_CheckNBit(&$2, 8); + $$ = $2; + } + | T_OP_SUB relocexpr { + rpn_UNNEG(&$$, &$2); + rpn_CheckNBit(&$$, 8); + } +; + reloc_16bit : relocexpr { rpn_CheckNBit(&$1, 16); $$ = $1; @@ -1863,9 +1874,9 @@ z80_ld : z80_ld_mem | z80_ld_a ; -z80_ld_hl : T_Z80_LD T_MODE_HL T_COMMA T_MODE_SP T_OP_ADD reloc_8bit { +z80_ld_hl : T_Z80_LD T_MODE_HL T_COMMA T_MODE_SP reloc_8bit_offset { out_AbsByte(0xF8); - out_RelByte(&$6, 1); + out_RelByte(&$5, 1); } | T_Z80_LD T_MODE_HL T_COMMA reloc_16bit { out_AbsByte(0x01 | (REG_HL << 4)); diff --git a/test/link/all-instructions.asm b/test/link/all-instructions.asm index 4e321ffc..84e5f301 100644 --- a/test/link/all-instructions.asm +++ b/test/link/all-instructions.asm @@ -220,6 +220,7 @@ jrlabel: add sp,$DB ld [$ABCD],sp ld hl,sp+$DB + ld hl,sp-$25 ld sp,hl pop af @@ -243,8 +244,6 @@ jrlabel: nop scf stop -BYTE = 0 -REPT 256 +FOR BYTE, 256 stop BYTE -BYTE = BYTE + 1 ENDR diff --git a/test/link/all-instructions.out.bin b/test/link/all-instructions.out.bin index d6c500e6..ddd5cdaf 100644 Binary files a/test/link/all-instructions.out.bin and b/test/link/all-instructions.out.bin differ