gbdev / rgbds

Rednex Game Boy Development System - An assembly toolchain for the Nintendo Game Boy and Game Boy Color
https://rgbds.gbdev.io
MIT License
1.35k stars 172 forks source link

The parser does not allow a minus sign in `ld hl, sp + <e8>` #864

Closed dctucker closed 3 years ago

dctucker commented 3 years ago

It seems introducing the requirement of T_OP_ADD to the ld hl, sp + <e8> instruction causes the parser to identify as a syntax error expressions such as ld hl, sp-$72 which may have previously been valid and must now be rewritten as ld hl, sp+-$72.

ERROR: game.asm(4) -> bank_000.asm(9186):
    syntax error, unexpected -, expecting +

Related issue: https://github.com/gbdev/rgbds/issues/810

ISSOtm commented 3 years ago

Wait, I thought ld hl , sp - expr was handled too!?

dctucker commented 3 years ago

I could be wrong, I'm working on Catalina with rgbds version 0.5.0 as distributed via Homebrew, so feel free to close if this has been addressed more recently 🙂.

I'm compiling this for reference, and it indeed compiles fine with a bulk search/replace adding the plus sign.

ISSOtm commented 3 years ago

Nope, you're right, it's not handled. https://github.com/gbdev/rgbds/blob/8e4ba8d2e436a985c77e08212b65dd31157dea3f/src/asm/parser.y#L1866

ISSOtm commented 3 years ago

We need a test case, too.