How to use a library(made in c/c++) in a MIPS
assembly program compiled using QtSpim
( MIPS
emulator) ? Using this forum I was able to do this using Intel assembly program by the help of a very talented person @rkhb. This was the solution that he provided:
how to use a library in masm or more specifcally a .lib file?
Now I want to do this same thing in MIPS
assembly. Now since I am using an Intel processor and using QtSpim
to run MIPS
assembly programs, how can I do this while using QtSpim
?
To call a C compiled function from assembler (or vice versa) the registers must have the following content:
If SPIM does not support loading executable files but only source code you may create a statically linked executable file and perform a disassembly.
You may pass the disassembly to the SPIM simulator.
Please note that the "system call" instructions ("syscall" or "syscall #n") have a different meaning in different operating systems. If the library contains system calls than you cannot use library written for Linux in SPIM and vice versa.
--- Edit ---
Library functions compiled with "-pic" switch must be called using "JALR $t9", so register 25 ("t9") holds the address of the function that is called.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.