Closed sarahmence closed 4 years ago
It looks like you're compiling multiple asm files at once, something like:
./mcc.py src/main.asm src/setup/init.asm
I can see what you're going for here - including the symbol table for things like init.asm to make it accessible in main.asm, then link the code together.
The ability to compile and link multiple asm files together is relatively new, and was added much more recently than when include_h
was added. As such, the semantics of include_h
may need to be revised since it was made for dynamic linking only and not static linking.
My suggestion is to change include_h setup/init.asm
to just include setup/init.asm
in main.asm. Then just compile main.asm (./mcc.py src/main.asm
). Essentially include all code into main.asm and just compile that one file.
If you want to be able to statically link multiple asm files and don't mind tweaking the compiler, I think this change should be sufficient:
In cmd_ir/core.py
, function include_from
change DynLinkFunction
into ExternFunction
:
self.scope[name] = ExternFunction(var.global_name.name,
var.params, var.returns)
I won't make this change right away because I may add proper static/dynamic linking to the assembler to bring it in line with Command IR/CBL
That fixed it. Thanks!
I am working on the same project as the previous issue (#21), with this file structure:
src/
setup/
init.asm
util/
regs.asm
main.asm
In
init.asm
, I have this code:In
main.asm
, I have this code:Since you fixed #21, I am able to assemble this code into object files successfully, however when linking, I get this error:
Can you fix this? Thanks in advance!