'How to assemble for MIPS cpu in the gnu assembler
I learning MIPS assembly and I want to assemble a MIPS assembly using as or gas command
Looking at the manual page I tried to assemble using
as -mips32 myfile.asm
But it said it is an unrecognized option
I also tried to use
as -march=r3000 myfile.asm
but that also didn't work it said
Assembler messages: Fatal error: invalid -march= option: `r3000'
So, how do you assemble MIPS assembly using the gnu assembler
Solution 1:[1]
Do you have a version of GNU Binutils built to target MIPS? It's not like clang where you can use clang -target mips -march=mips1 -c foo.s && llvm-objdump -d foo.o (MIPS1 includes R2000 and R3000).
For example, to run GAS for ARM on my x86-64 desktop, I can run arm-none-eabi-as since I installed the arm-none-eabi-binutils package on my Arch Linux system. You'd need something similar, or configure and build Binutils from source yourself, to get a mips-something-something-as executable you could run.
Just plain as (/usr/bin/as) will be a native assembler for your system, so x86-64 if you're on x86-64, with no support for other ISAs. (Except for i386 with as --32 because Binutils considers amd64 and i386 as different versions of the same ISA).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Peter Cordes |
