I'd like translate my c codes to mips assembly using llvm. How can i do it? I'm on Mac. So llc command does not work.
Thanks
The clang on your MacOS system won't compile for mips by default, you'll need to build your own.
You can look here: http://llvm.org/docs/GettingStarted.html for directions on building up llvm.
After that you can use clang to compile C to mips assembly by doing something like:
clang -target mipsel-linux-gnu foo.c -S -o -
which will compile the file "foo.c" to 32-bit mips assembly for the linux operating system and output it to the console.
Related
I have generated an assembly file try.s with aarch64 instruction set.I want to compile this on an ARM8 (aarch64 processor) running ubuntu.
my native compiler is gcc(4.8) and i use the following command to compile
gcc -o try.o try.s
I am getting the following errors
Error : ARM register expected -- mov x10,x0
It seems like the aarch4 registers are not being recognized although i thought gcc 4.8 supported aarch64. Can someone tell me what am i missing or is there any special option i should include.Or suggest me a native compiler(not cross-compilers) for doing aarch64.I would also like to use gdb to debug this natively.
gcc is for a 32b targets. 'Xn' registers are not defined for a aarch32 instruction set. That's what compiler tells you.
Right toolchain is aarch64-elf-gcc.
PS: that's a good idea to make asm file extention .S (capital s)
I'm trying to compile a C program that has some inline assembly code in Intel format. I'm using GCC 4.9 (installed via Homebrew) on Mac 10.9, and the compiler flags:
gcc-4.9 -m32 -masm=intel -std=gnu99 get_rating.c
Unfortunately I get an error:
error: -masm=intel not supported in this configuration
I've tried many different combinations of the flags, but I keep getting that error. I can't leave out the -masm=intel flag, because the code I'm trying to compile uses Intel.
How can I compile the program? Is it at all possible on my Mac (version 10.9) or do I need to run a virtual machine?
The GCC docs state that Darwin does not support intel, so it seems you are out of luck with the direct approach. Virtual machine as you suggested, cross compiling, converting the assembler to att, and replacing the assembler with C are among your options - which is best for you you'll have to figure out.
HTH
i want to compile my c code in vle PowerPc instructions. how can i do so using gnu gcc or codebench csgnu gcc? i tried -eabi=vle but the resulting code did not contain valid vle instructions.
thanx
There are currently the following third-party GCC VLE toolchains available: NXP (S32), Mentro (CodeSourcery) and STM (SPC5-Studio).
Try -mvle
I know that to compile to assembly, I should use the -Soption with gcc or g++, but how do I get MIPS assembly?
I tried
g++ -march=mips2 dll.c
but that gives the error
dll.c:1:0: error: bad value (mips2) for -march= switch
I saw a suggestion of the compile command mips_gcc, but I can't find how to install that compiler.
I'm using Ubuntu 64-bit, if that helps.
You need a version of gcc that is built as a MIPS cross compiler. You can download the free Mentor/Codesourcery MIPS gnu/gcc cross compilation tool chain from here. This toolchain is available for both Windows and Linux.
After downloading, installing and adding the tool chain to your path you would say:
mips-linux-gnu-g++ -march=mips32r2 -S dll.c
to compile your code to MIPS32R2 assembly.
UPDATE 8/2017:
It looks like Sourcery CodeBench free cross compiler for MIPS is no longer available at Mentor's site.
Try the free toolchain at Imagination's site.
For a school assignment I have to write x86 assembly code, except I can't use gcc to compile it since my computer is an x64 machine, and gcc is only excpecting x86 code. Is there a command that'll make gcc accept it x86 assembly code? Thanks
P.S. I know my code is valid since it compiles just fine on x86 machines.
Just pass the -m32 option to gcc.