Search code examples
linkermipsmips32mars-simulator

MARS, MIPS assembler, linking two files together?


I have a quick question. I am using MARS assembler (programming in the MIPS instruction set) and I have two MIPS files. One file contains my main method to be run and it calls a function in the other file. My function has the .globl directive before it, but every time I try and compile my program it says

Symbol "print_hex" not found in symbol table.

Here is a screen shot for more context: enter image description here

The label print_hex is located in the file called print_hex.s.

enter image description here

How can I link these two files together? Lastly, how can I tell MARS to call a specific label at the start of execution, for example I want it to call main.


Solution

    1. Put the files in the same directory
    2. Enable the MARS option Settings->Assemble all files in directory
    3. Assemble the file you want to start execution at.

    And then all the files in the directory should get assembled and linked together.

    To always have execution start at your main label, you can enable Settings->Initialize program counter to global 'main'.