Closed chrisgbk closed 1 year ago
#subruledef cpu6502_reladdr
{
{addr: u16} =>
{
reladdr = addr - $ - 2
assert(reladdr <= 0x7f)
assert(reladdr >= !0x7f)
reladdr`8
}
}
#ruledef cpu6502
{
bcc {addr: cpu6502_reladdr} => 0x90 @ addr
}
#ruledef cpu6502_macro
{
bccmacro {addr: cpu6502_reladdr} => asm{bcc {addr}}
}
bcc 120
bccmacro 16384
bcc 120
outp | addr | data (base 16)
0:0 | 0 | 90 76 ; bcc 120
2:0 | 2 | ; bccmacro 16384
2:0 | 2 | 90 74 ; bcc 120
An extra test; asm{...} seems very broken currently.
I've managed to fix both errors, and I'll release a new version soon! Thank you so much for the reports!
This will happily assemble. In my view, the 121 should hit the assert and fail, before the attempt to call asm{...}
In my specific use case, I have instruction macros that have different encodings but the same length depending on the range of a value, but this behavior results in an inability of the assembler to catch which one is the wrong one, as they are all accepted as being correct encodings without any assert failures.
As a workaround, I can move every assert out of the subruledef, but this results in a lot of duplication.