Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Translate from c to asm

Reply
Thread Tools

Translate from c to asm

 
 
Ronny Mandal
Guest
Posts: n/a
 
      12-07-2003
Hello!

Can anyone please provide me some resources, or maybe an algorithm / tip on
translating from c to assembler (arbitrary assembler, but LC2 is preferred.
The c-routines themselves are small, trivial ones). I hvae an exam in a
computer science course in 4 days, and I simply cannot get a grip on this
topic.

Any help would be highly appreciated.


Regards,

Ronny Mandal


 
Reply With Quote
 
 
 
 
mhandis
Guest
Posts: n/a
 
      12-07-2003
Try GCC's -S argument:

gcc -S test.c

This should create an assembly version called test.s.

Ronny Mandal wrote:
> Hello!
>
> Can anyone please provide me some resources, or maybe an algorithm / tip on
> translating from c to assembler (arbitrary assembler, but LC2 is preferred.
> The c-routines themselves are small, trivial ones). I hvae an exam in a
> computer science course in 4 days, and I simply cannot get a grip on this
> topic.
>
> Any help would be highly appreciated.
>
>
> Regards,
>
> Ronny Mandal
>
>

 
Reply With Quote
 
 
 
 
Thomas Matthews
Guest
Posts: n/a
 
      12-07-2003
Ronny Mandal wrote:
> Hello!
>
> Can anyone please provide me some resources, or maybe an algorithm / tip on
> translating from c to assembler (arbitrary assembler, but LC2 is preferred.
> The c-routines themselves are small, trivial ones). I hvae an exam in a
> computer science course in 4 days, and I simply cannot get a grip on this
> topic.
>
> Any help would be highly appreciated.
>
>
> Regards,
>
> Ronny Mandal
>
>


Check you compiler documentation. Many have an option for creating
assembly language listings. Also check your debugger documentation.
Some debugger's have this capability too. You may want to see if
they have "interwoven" capability, which is to print a C language
statement, then followed by the assembly language. This would
be very helpful since you can see what assembly language was created
for each C statement.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library

 
Reply With Quote
 
nrk
Guest
Posts: n/a
 
      12-07-2003
mhandis wrote:

> Try GCC's -S argument:
>
> gcc -S test.c
>
> This should create an assembly version called test.s.
>
> Ronny Mandal wrote:
>> Hello!
>>
>> Can anyone please provide me some resources, or maybe an algorithm / tip
>> on translating from c to assembler (arbitrary assembler, but LC2 is
>> preferred. The c-routines themselves are small, trivial ones). I hvae an
>> exam in a computer science course in 4 days, and I simply cannot get a
>> grip on this topic.
>>
>> Any help would be highly appreciated.
>>
>>
>> Regards,
>>
>> Ronny Mandal
>>
>>

On a related and totally off-topic note, does anyone have a good,
comprehensive, online reference for the AT&T assembler syntax? I've tried
to find one, and always come up short.

-nrk.
 
Reply With Quote
 
CBFalconer
Guest
Posts: n/a
 
      12-07-2003
Ronny Mandal wrote:
>
> Can anyone please provide me some resources, or maybe an algorithm
> / tip on translating from c to assembler (arbitrary assembler, but
> LC2 is preferred. The c-routines themselves are small, trivial
> ones). I hvae an exam in a computer science course in 4 days, and
> I simply cannot get a grip on this topic.


All you have to do is be able to code in assembly. The normal way
of performing the transformation is via a compiler whose output
phase was designed by someone so capable, but hand compilation is
also acceptable. In any case you have to understand the
destination machine.

I suspect you are going to fail.

--
Chuck F () ()
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!


 
Reply With Quote
 
Irrwahn Grausewitz
Guest
Posts: n/a
 
      12-07-2003
nrk <> wrote:
> mhandis wrote:
> > Ronny Mandal wrote:
> >> Can anyone please provide me some resources, or maybe an algorithm / tip
> >> on translating from c to assembler

> >
> > Try GCC's -S argument:
> >
> > gcc -S test.c

>
> On a related and totally off-topic note, does anyone have a good,
> comprehensive, online reference for the AT&T assembler syntax? I've tried
> to find one, and always come up short.


[still way OT:]

I had the same problem, but found out that you can make gcc
generate Intel syntax assembler:

gcc -S -masm=intel test.c

Regards
--
Irrwahn Grausewitz ()
welcome to clc : http://www.angelfire.com/ms3/bchambl...me_to_clc.html
clc faq-list : http://www.eskimo.com/~scs/C-faq/top.html
acllc-c++ faq : http://www.contrib.andrew.cmu.edu/~a...acllc-c++.html
 
Reply With Quote
 
Nejat AYDIN
Guest
Posts: n/a
 
      12-07-2003
nrk wrote:
>
> mhandis wrote:

[...]
> On a related and totally off-topic note, does anyone have a good,
> comprehensive, online reference for the AT&T assembler syntax? I've tried
> to find one, and always come up short.


Did you try "man as", or online GNU documentation such as,
http://www.gnu.org/software/binutils...er/as_toc.html

http://www.gnu.org/software/binutils...16.html#SEC196
 
Reply With Quote
 
Kevin Goodsell
Guest
Posts: n/a
 
      12-07-2003
Ronny Mandal wrote:

> Hello!
>
> Can anyone please provide me some resources, or maybe an algorithm / tip on
> translating from c to assembler (arbitrary assembler, but LC2 is preferred.
> The c-routines themselves are small, trivial ones). I hvae an exam in a
> computer science course in 4 days, and I simply cannot get a grip on this
> topic.
>


Translating C to an assembler is very unlikely to be possible in most
cases. The only way you could get an assembler out of a C source is if
that source happens to be the source for an assembler. If I take the
source for a C "hello world" program, about the only thing it can be
translated into is a "hello world" program (usually either in machine
language or assembly language). It can't be translated into an assembler
any more than it could be translated into an editor or a compiler - the
logic just isn't there.

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.

 
Reply With Quote
 
Ronny Mandal
Guest
Posts: n/a
 
      12-07-2003

"CBFalconer" <> wrote in message
news:...
> Ronny Mandal wrote:
> >
> > Can anyone please provide me some resources, or maybe an algorithm
> > / tip on translating from c to assembler (arbitrary assembler, but
> > LC2 is preferred. The c-routines themselves are small, trivial
> > ones). I hvae an exam in a computer science course in 4 days, and
> > I simply cannot get a grip on this topic.

>
> All you have to do is be able to code in assembly. The normal way
> of performing the transformation is via a compiler whose output
> phase was designed by someone so capable, but hand compilation is
> also acceptable. In any case you have to understand the
> destination machine.
>
> I suspect you are going to fail.


I think you're almost right. But it is approx. 4 days remaining, so a little
intensivereading won't hurt.
The programs that are to be translated are only like "Hello World, etc",
hence the chances are good indeed!

RM


 
Reply With Quote
 
Anuj Heer
Guest
Posts: n/a
 
      12-08-2003
Actually there are disassemblers available on the internet which can
convert full exe codes back into assembly language. You can also find
decompilers which can convert EXE files back to C codes. But these
programs come with a lot of extra overhead as they convert the whole
code on a as is where is basis to the end code and will make your life
hell trying just to figure out where the actual usable code segment
is. Studying hard can solve the problem in just one night. But if you
still want those just mail me asap at hp-.

anuj
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
define byte asm substitute? Edwin Knoppert ASP .Net 0 01-11-2006 02:06 PM
ASM (vs. BCEL) - can I do this? Francesco Devittori Java 2 12-21-2005 11:01 AM
ANN: 9Rays.Spices.Net [asm.browser, analyzer, obfuscator, decompiler, modeler]v3.4.2 released Al Ponomarev ASP .Net 3 05-03-2004 07:52 PM
OLD CISCO ASM CSC3 - Terminal line configuration Joe Bloggs Cisco 0 01-21-2004 02:02 PM
ASM Help toddneumiller Java 8 11-09-2003 08:24 AM



Advertisments