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)
views:
94answers:
2
+3
A:
- Get a C compiler that can output MIPS code - there is probably a version of gcc that will do.
gcc -S
your source code. Alternatively, compile into an object file and then useobjdump
to disassemble it.
Presto - code translated from C to assembly!
Carl Norum
2010-09-08 16:27:51
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
2010-09-08 16:33:19
@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
2010-09-08 16:36:42
it's difficult for me now to get a c compiler. can anyone please find me the answer and post it here?thnx
efi
2010-09-08 17:20:26
@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
2010-09-08 17:21:49
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
2010-09-08 17:52:48
@efi, if that code was on a past exam, it was impossible. The code you've shown isn't valid C.
Carl Norum
2010-09-08 17:53:35
maybe i have make a mistake because i don't remember it exactly.
efi
2010-09-08 18:07:21
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
2010-09-08 16:30:10