Redefined proposed syntax for preprocessor in TODO.org

This commit is contained in:
2023-11-05 16:20:14 +00:00
parent a3d8e5ee1f
commit aadb21853a

View File

@@ -35,37 +35,30 @@ Something to consider is /static/ and /dynamic/ "linking" i.e.:
+ 63 bit references user code (not a lot of loss in precision)
+ Easy to check if a reference is a library reference or a user
code reference by checking "sign bit" (negativity)
* TODO Inlining subroutines :ASM:
Essentially consider the following situation
* TODO Preprocessing directives :ASM:
Like in FASM or NASM where we can give certain helpful instructions to
the assembler. I'd use the ~%~ symbol to designate preprocessor
directives.
** TODO Constants
Essentially a directive which assigns some literal to a symbol as a
constant. Something like
#+begin_src asm
global _start
a:
push.word 1
push.word 1
plus.word
print.word
ret
_start:
call a
halt
%const:n:20%end
#+end_src
What I'd like to be able to do is:
Where you'd refer to the definition using ~$n~. The assembler will
look for symbols like ~$n~ and insert definitions it finds for them.
Can be useful when defining data type bounds and other useful constants.
2023-11-04: You could even put full program instructions for a
constant potentially
#+begin_src asm
global _start
%inline:a:
%const:print-1:
push.word 1
push.word 1
plus.word
print.word
ret
%end
_start:
%inline a
halt
#+end_src
This is equivalent in LOC, but in terms of the actually output
instructions the second is smaller in size, doesn't use any jumps nor
does it use the call stack. As a result it's a linear program.
which when referred to ~$print-1~ would just insert the bytecode given inline.
* Completed
** DONE Write a label/jump system :ASM:
Essentially a user should be able to write arbitrary labels (maybe