I couldn't help myself and decided to make the assembler handle macros. You can pass arguments to macros, which get expanded in-place. The way symbols are resolved probably has awful computational complexity. All expansions to however many levels are done recursively twice, once to resolve constants and labels, and again to generate code.
One thing this can't do is accept another macro as an argument to a macro expansion, although I'm not sure either how to express that syntactically or how to implement it. I'm also not sure that's really necessary. Right now it spits out a ton of debug messages. https://sourceforge.net/p/educpu/code/ci/master/tree/tools/ Example code: # subroutine call macro .call @lb # Push previous return addr onto stack subi r30,r30,1 st r31,r30,0 # Make the call bt @lb,r31 # Pop previous return addr ld r31,r30,0 addi r30,r30,1 end # return from sub macro .ret jmp r31 end @start = 10 @n = 3 ori r2,r0,@start ori r1,r0,@n @loop: #addi r2,r2,1 .call @mysub subi r1,r1,1 bne @loop nop halt @mysub: addi r2,r2,1 .ret nop -- Timothy Normand Miller, PhD Assistant Professor of Computer Science, Binghamton University http://www.cs.binghamton.edu/~millerti/ Open Graphics Project
_______________________________________________ Open-graphics mailing list [email protected] http://lists.duskglow.com/mailman/listinfo/open-graphics List service provided by Duskglow Consulting, LLC (www.duskglow.com)
