Post Reply 
 
Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
compile C to ASM
01-25-2013, 11:56 AM
Post: #1
Not Solved compile C to ASM
I'm posting a vague question for my sister who is having trouble with her home work.
She called me asking if I knew of a program that could compile her 27 pages of C code into assembly or. ASM? It's for a micro controller that's a glove that when making a strum motion emits a guitar sound
as always any reply is appreciated
Find all posts by this user
Quote this message in a reply
01-25-2013, 01:26 PM
Post: #2
Not Solved RE: compile C to ASM
If she's using Linux, she can use gcc from the command line with (I think) the -S switch.

Raidmax Smilodon
AMD FX-8350 | Noctua NH-U12S cooler
GeForce GTX 960
8GB RAM
Visit this user's website Find all posts by this user
Quote this message in a reply
01-25-2013, 02:27 PM
Post: #3
Not Solved RE: compile C to ASM
I told her I thought cygwin would do it because she's using win7 but I appreciate the reply
Find all posts by this user
Quote this message in a reply
01-25-2013, 05:57 PM
Post: #4
Not Solved RE: compile C to ASM
In cygwin she can use the dash s switch as RWenger suggested, but the gcc compiler would likely create assembly output for Linux. If she wanted to use a Windows compiler to create Windows assembly code, she would need to refer to specific documentation per that compiler. Also it wouldn't create Windows API calls in the assembly code. It would also be assembly code as the compiler saw fit. It isn't going to have variable names & such.

-#2pencil-

[Image: lovelinux.gif]
Visit this user's website Find all posts by this user
Quote this message in a reply
06-30-2013, 01:33 PM
Post: #5
Not Solved RE: compile C to ASM
(01-25-2013 05:57 PM)no2pencil Wrote:  In cygwin she can use the dash s switch as RWenger suggested, but the gcc compiler would likely create assembly output for Linux. If she wanted to use a Windows compiler to create Windows assembly code, she would need to refer to specific documentation per that compiler. Also it wouldn't create Windows API calls in the assembly code. It would also be assembly code as the compiler saw fit. It isn't going to have variable names & such.


This is true, there will not be any variable names. And there will be a lot of assembly code there. She could possible rewrite her code in assembly, MASM32 has macros for if/else/else if, and various other high level language terms. MASM32 also has Windows API bindings so you can call Windows functions. However, you have to declare the function arguments in the wrong order (And other functions too), like this:

Code:
invoke MessageBox, MB_ICONERROR, TITLE, TEXT, NULL

Instead of this, in C/C++:
Code:
MessageBox(NULL, L"Hello, World!", L"Example", MB_ICONERROR);

A comparison in pure assembly syntax would be something like this:

Code:
mov eax, 1
mov ebx, 0
cmp eax, ebx
je equal
jne nequal
jmp else
equal:
; equal to
jmp stop
nequal:
; not equal to
jmp stop
else:
; some unknown error
stop:

So, the logic is very simple. it just requires a different way of thinking.

Also, couldn't you just compile the code for the desired processor architecture? Or do you specifically need in in assembly?
Visit this user's website Find all posts by this user
Quote this message in a reply
07-03-2013, 04:24 PM (This post was last modified: 07-03-2013 04:25 PM by no2pencil.)
Post: #6
Not Solved RE: compile C to ASM
(06-30-2013 01:33 PM)echo off Wrote:  However, you have to declare the function arguments in the wrong order (And other functions too), like this:
It's not "The wrong order", it's a matter of understand how a stack works. First in, last out.

-#2pencil-

[Image: lovelinux.gif]
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)