vhelin / wla-dx

WLA DX - Yet Another GB-Z80/Z80/Z80N/6502/65C02/65CE02/65816/68000/6800/6801/6809/8008/8080/HUC6280/SPC-700/SuperFX Multi Platform Cross Assembler Package
Other
546 stars 98 forks source link

Improve: Remove g_input_parse_if and make A == B etc. conditions to produce a correct result, everywhere #579

Closed vhelin closed 1 year ago

vhelin commented 1 year ago

The title says it all. Currently .IF forces the parser into a mode that can calculate A == B properly. If possible, make such calculations to work everywhere.

vhelin commented 1 year ago

This includes making '<' (get low byte) etc. to work inside .IFs.

vhelin commented 1 year ago

I've already completed this feature. Could not get totally rid of g_input_parse_if (because of NOT (!)), but otherwise the feature seems to work, all of my tests pass.

Anyway, I'll push this to master right after v10.5 is released hopefully EDIT: in a week...

maxim-zhao commented 1 year ago

This does introduce some regressions in old code. In WLA DX, there's a bunch of places where we have lists of parameters with optional comma separators, and in general the parser will greedily consume things that look like expressions. Thus:

.db 1 2 3 4 5 ; 5 bytes
.db 1 -2 3 -4 5 ; 3 bytes!
.db 1, -2, 3, -4, 5 ; 5 bytes because we added commas

This change makes ">" and "<" able to act as binary operators in this context, so this code changes meaning

.db 1 <label 2 >label ; Used to be 4 bytes, now two (I think) - 1s or 0s depending on the label value

Having said that... I suspect it's better to fix up that old code rather than try to handle it gracefully.

vhelin commented 1 year ago

Having said that... I suspect it's better to fix up that old code rather than try to handle it gracefully.

I agree. Just thinking if there would be a way of helping the user to avoid such problematic situations... At least I can add a warning about this to the documentation.