Implementing semantic register aliasing for nasm

I've read on twitter from @16kbps "why doesn't asm have local aliases for registers". And I thought - "well, how hard can it be?".

Turns out the first quick hack is about an hour hard.

The result is this patch below to nasm (latest git version from https://repo.or.cz/w/nasm.git, that allows you to do stuff like:

%rdefine foobar_test ax
        mov foobar_test, 1
#        mov foobar2_test, 2
%rdefine foobar2_test ax
#        mov foobar_test, 3
        mov foobar2_test, 4

The resulting assembly is:

        mov ax, 1
        mov ax, 4

Uncommenting either of the two commented lines will cause the compile error, which is a nice side effect.

TODO: make it clear out on branch/call.

Index of /blog/2019-11-26-Implementing-semantic-register-aliasing-for-nasm/

NameLast ModifiedSizeType
Parent Directory/ -  Directory
0001-Implement-rdefine-which-aims-to-help-with-symbolic-r.patch2019-Nov-26 00:49:502.7Ktext/x-diff
lighttpd/1.4.33