Closed douggilliland closed 5 years ago
@douggilliland would #DEFINE
work like a standard c-style precompiler directive?
E.g. #define SOME_A SOME_B
basically means replace every occurrence of SOME_A
with SOME_B
in the file? Should it span files or only work in the file containing the #define
?
@mjgpy3 Yep, just like C. Doesn't probably matter if it is local to the file or persists into the include files.
Is it okay to require that #define
comes before usage of the term it defines? I shouldn't need another pass if this is acceptable.
Also, I'm going to restrict the definable terms to alphanumeric plus _
if that's okay.
I know C let's one do some pretty crazy stuff with these :)
Also I'm going to make this replace at the token level. In other words crazy things like the following aren't allowed.
#DEFINE dr di
addr r10, r11, 42
To try to get
addi r10, r11, 42
@mjgpy3 Something like #define could be very helpful for keeping tracks of constants - like the ports in the memory map.
Would be something like the C version:
define _SERIAL_PORT_BASE 0x1000
Then it could be used with something like:
lix r9,_SERIAL_PORT_BASE.lower