How to convert c++ code to 68000 Motorola assembly code?

Uchiha

New member
Joined
Mar 8, 2010
Messages
16
Reaction score
0
Points
1
i am trying to convert my code into assembly code, and all i can find on google is at&t syntax, and its super annoying!!!
but i need to figure out how to convert this into the 68000 motorola assembly code, anything will help, i am also stuck on how to declare my parameters.

int foo(int n, int m);

int main() {
int n, m;
cin >> n;
cin >> m;
cout << f(n,m) << endl;
return 0;
}

int foo(int n, int m) {
if (m==0)
return n;
else
return foo(n+1, m-1);

}
 
The GNU C++ compiler will generate assembler for the target machine (68000) as an optional output. If you want to do it all by hand you will be facing quite a job.




8.20 How to get GCC to generate assembly code

Q: How can I peek at the assembly code generated by GCC?

Q: How can I create a file where I can see the C code and its assembly translation together?

A: Use the -S (note: capital S) switch to GCC, and it will emit the assembly code to a file with a .s extension. For example, the following command:

gcc -O2 -S -c foo.c
will leave the generated assembly code on the file foo.s.

If you want to see the C code together with the assembly it was converted to, use a command line like this:

gcc -c -g -Wa,-a,-ad [other GCC options] foo.c > foo.lst
which will output the combined C/assembly listing to the file foo.lst.

If you need to both get the assembly code and to compile/link the program, you can either give the -save-temps option to GCC (which will leave all the temporary files including the .s file in the current directory), or use the -Wa,-aln=foo.s option which instructs the assembler to output the assembly translation of the C code (together with the hex machine code and some additional info) to the file named after the =.
 
Back
Top