How to link multiple assembler files for MMIX

639 views Asked by At

Assume, I wrote a small lib implementing something "fprint"-likely. The book that teaches me MMIX (Das MMIX-Buch, german) always copies the whole lib into the new program, but I dislike this approach. Is there any way to assemble the library into one object file, the main program into another and link these two together? How to do this?

2

There are 2 answers

0
Martin Ruckert On BEST ANSWER

Check the mmix repository www.mmix.cs.hm.edu there are two examples in the examples folder: Hello World GNU, descrobes step by step how to get and use the GNU Tools and compile and link hello.s (assembler) or hello.c linked with the C library and a second example, running MMIX on MMIX which links together the MMIX executable for MMIX from different c files, and linking together several assembler files and a C library to implement a fat32 file system for MMIX. Martin

1
Jester On

According to what I have learned from a brief internet search, the mmix tools use the normal gcc and binutils packages. As such, I expect multiple object files and even standard static libraries to "just work". I wonder what exact problem you have run into.

gcc -c lib.c -o lib.o
gcc -c main.c -o main.o
gcc lib.o main.o -o program

EDIT: obviously similar for asm sources, just use .s or .S extension. You can of course use the appropriate assembler and linker commands that gcc uses behind the scenes too. The command line option -v will show those.