Kingcom / armips

An assembler for various ARM and MIPS platforms. Builds available at http://buildbot.orphis.net/armips/
MIT License
363 stars 77 forks source link

Fix macro argument error with dollar-prefixed registers #210

Closed Thar0 closed 2 years ago

Thar0 commented 2 years ago

Fixes an issue I encountered in trying to use dollar-prefixed registers as macro arguments. For example, before the fix the following would error with "Invalid macro argument expression":

.rsp
.macro vclr, dst
    vxor dst, dst, dst
.endmacro

.create "test.bin", 0x1000

    vclr $v0

.close

I'm unsure if this fix is totally correct, or if it may break something else, however all existing tests pass. I will be glad to receive any feedback.

Kingcom commented 2 years ago

Hm... this does fix the issue in this case, but mostly by chance. I guess parsing the parameters as an expression is a crutch to begin with. It is really only done to find out how many tokens to use. Perhaps it's a better idea to instead treat it as a comma separated list of any random sequence of tokens here (i.e. take anything until the next comma or separator token).

Commas don't appear in expressions, so this should be relatively safe to do.

Kingcom commented 2 years ago

Looks good. Can you adjust the Too many macro arguments check below the loop too? And ideally squash the commits.

Thar0 commented 2 years ago

Done, I hope this is what you had in mind for the check.

Kingcom commented 2 years ago

Yeah, looks good! Thanks.