Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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 :

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).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading