tags:

views:

94

answers:

2
int x=0;
int A[50,100];
main() {
j=bin_search (*A , item, Nelem){
temp=0;
temp=Nelem/2;
if(Nelem==1)
 return *x;
else (*x<item)
return bin_search(*x , item , temp)
else
return bin_search(*x+temp , item , temp)
+3  A: 
  1. Get a C compiler that can output MIPS code - there is probably a version of gcc that will do.
  2. gcc -S your source code. Alternatively, compile into an object file and then use objdump to disassemble it.

Presto - code translated from C to assembly!

Carl Norum
1. I think that the following explains how to do this with -march http://gcc.gnu.org/onlinedocs/gcc-3.3.6/gcc/MIPS-Options.html
Dana the Sane
@Dana, yeah - but you still need a compiler with MIPS support built-in. I guess most normal situations don't include such a thing (unless you're running on a MIPS machine, I guess). A cross-compiler is likely to be necessary.
Carl Norum
it's difficult for me now to get a c compiler. can anyone please find me the answer and post it here?thnx
efi
@efi, I think with that statement you just guaranteed nobody is going to help you. What's the problem with getting a compiler?
Carl Norum
i'm not lazy but i don't know how to use it. this code was an exercise in a past exam and i'm trying to solve it by hand
efi
@efi, if that code was on a past exam, it was impossible. The code you've shown isn't valid C.
Carl Norum
maybe i have make a mistake because i don't remember it exactly.
efi
A: 

If you're struggling you could use a cross-compiler set for the given CPU architecture to compile the C program and output the intermediate assembly instructions for your target architecture. GCC should be able to do this without too much trouble. If you're looking for a clean easy to read translation make sure to disable most or all optimizations.

bot403