473,882 Members | 1,695 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Translate from c to asm

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
Nov 13 '05
17 12554
Ronny Mandal wrote:
"CBFalconer " <cb********@yah oo.com> wrote in message
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 intensivereadin g won't hurt.
The programs that are to be translated are only like "Hello World,
etc", hence the chances are good indeed!


Then simplify the problem. Assume you have a puts subroutine
available, and all the program has to do is supply it the
appropriate parameters, and then return a status. So you have to
look up how to pass parameters, how to call a subroutine, and how
to exit a routine with a value. You can simplify parameter
passing to pushing onto a stack on most systems, don't know about
yours. Others require using registers.

You should have done all this months ago.

--
Chuck F (cb********@yah oo.com) (cb********@wor ldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net> USE worldnet address!
Nov 13 '05 #11
hp*****@vcustom er.net (Anuj Heer) wrote in message news:<86******* *************** ****@posting.go ogle.com>...
Actually there are disassemblers available on the internet which can
convert full exe codes back into assembly language


Hey there!

You don't need to jump the gun that far.. I think most compilers have
an assembly intermediate stage. This is definately true of gcc and
Turbo C.

To the OP: the assembly code generated by a compiler can tend to be
distinguishable from hand-written assembly. There is a fairly good
chance that if you try to hand in compiler-generated assembly, you
will be caught out. Stripping out the comments will not do.

It is not impossible to pick up a good bit of asm in a couple of days
if you really put your mind to it.
David.
Nov 13 '05 #12
dw***********@b otanicus.net (David M. Wilson) wrote in message news:<99******* *************** ****@posting.go ogle.com>...
hp*****@vcustom er.net (Anuj Heer) wrote in message news:<86******* *************** ****@posting.go ogle.com>...
Actually there are disassemblers available on the internet which can
convert full exe codes back into assembly language
Hey there!

You don't need to jump the gun that far.. I think most compilers have
an assembly intermediate stage. This is definately true of gcc and
Turbo C.


agreed totally!!!
To the OP: the assembly code generated by a compiler can tend to be
distinguishable from hand-written assembly. There is a fairly good
chance that if you try to hand in compiler-generated assembly, you
will be caught out. Stripping out the comments will not do.
yes, examiners who have been at it for quite some time can smell such
code from miles away.
It is not impossible to pick up a good bit of asm in a couple of days
if you really put your mind to it.
David.


that as everyone has said already would be the best approach unless
you don't like programming which will make it the most difficult task
of your life

anuj
hp*****@vcustom er.net
Nov 13 '05 #13
Mac
On Sun, 07 Dec 2003 19:39:37 +0000, Kevin Goodsell wrote:
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


You are trying awfully hard to be pedantic, but the usage of the term
"assembler" to mean "assembly language" is quite widespread. If you want
to assert that it is unambiguously wrong, I think you have to quote an
authoritative source of some sort.

Mac

Nov 14 '05 #14
Mac wrote:
On Sun, 07 Dec 2003 19:39:37 +0000, Kevin Goodsell wrote:

You are trying awfully hard to be pedantic, but the usage of the term
"assembler" to mean "assembly language" is quite widespread.


Oh, is /that/ what he meant?

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

Nov 14 '05 #15
Kevin Goodsell <us************ *********@never box.com> wrote in message news:<Zl******* **********@news read1.news.pas. earthlink.net>. ..
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


Hmmm...

In every IDE I've seen (not an exhaustive list but certainly
representative) one can set the simulator/emulator window to
display C (C++) interspersed with assembly. Tag-and-drag to
whatever editor is available, comment out the C, edit out the
extraneous fields of line numbers and machine code, change the
compiler-provided names to something that the assembler will
eat and, VOILA, you have a thorough understanding of how the
compiler works and a decent head-start on learning the specific
assembly language of the selected micro.

Realizing that this does not meet the OP's timeline or, perhaps,
LC2 requirement (too lazy to google) it still provides the
foundation for making an excellent living.

Regards,
Ken Asbury
Nov 14 '05 #16
nrk
Nejat AYDIN wrote:
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

Thanks, I have perused them in the past (indeed, that's the only way I could
make any sense out of AT&T style asm generated by gcc by default).
However, I've always wondered if that is the best and comprehensive
reference of the AT&T syntax... certainly the best I've managed to find
(barring a few djgpp related web pages) in the past.

-nrk.
Nov 14 '05 #17
nrk
Irrwahn Grausewitz wrote:
nrk <ra*********@de adbeef.verizon. net> 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


Duh!! Never even occurred to me that gcc could be asked to generate
assembler output in a different dialect (go on, I know how dumb I am)!!

Now, this is good for me (confession time: I prefer the Intel syntax as I am
more comfortable with it, and AT&T's switch of source, destination was hard
to cope with).

Thank you,
-nrk.
Nov 14 '05 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2344
by: Bengt Richter | last post by:
Just thought None as the first argument would be both handy and mnemonic, signifying no translation, but allowing easy expression of deleting characters, e.g., s = s.translate(None, 'badcharshere') Regards, Bengt Richter
1
2033
by: shank | last post by:
I'm sure this is a stretch, but is there some kind of component that I could install to translate from English to Spanish on the fly? I have a lot of equipment features and specifications that I could manually translate, but that's labor intensive. I know there are services were I can paste a URL and it will translate the page, but I don't want to send users away from the site, unless I could do so transparently. Does anyone else have...
4
2174
by: Gadrin77 | last post by:
I have data that looks like <Root> <Main Value="Line1|Line2.|Line3|Line4.|Line5"/> </Root> I'm using Translate(@Value, "|.", ",")
6
2790
by: bobueland | last post by:
The module string has a function called translate. I tried to find the source code for that function. In: C:\Python24\Lib there is one file called string.py I open it and it says
6
5590
by: Anders K. Olsen | last post by:
Hello group I'm trying to list the users and groups who has read access to a file. I use .NET 2.0 and FileInfo.GetAccessControl().GetAccessRules(...) and then loop through the FileSystemAccessRule objects. Using these objects, it is easy to use rule.IdentityReference.Translate(typeof(NTAccount)) to get the NTAccount object. I have noticed that some of the NTAccounts can belong to BUILTIN domains,
1
9398
by: peterbe | last post by:
This has always worked fine for me. Peter fine Now if I do it with a unicode string: Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/lib/python2.4/string.py", line 493, in translate return s.translate(table, deletions) TypeError: translate() takes exactly one argument (2 given)
9
3121
bvdet
by: bvdet | last post by:
I have done some more work on a simple class I wrote to calculate a global coordinate in 3D given a local coordinate: ## Basis3D.py Version 1.02 (module macrolib.Basis3D) ## Copyright (c) 2006 Bruce Vaughan, BV Detailing & Design, Inc. ## All rights reserved. ## NOT FOR SALE. The software is provided "as is" without any warranty. ############################################################################ """ Class...
1
2566
by: =?Utf-8?B?R2F1cmF2?= | last post by:
Hi, I am using the Translate() function in one of the .XSLT file to remove the spaces, like this: <xsl:for-each select=".//Illustration"> <xsl:value-of select="translate(./@illusName, ' ', '')"/> …. This works fine with command line msxsl and XML editors like XMLSpy. However, if you use .NET's
3
4720
by: Kenneth McDonald | last post by:
I have the need to occasionally translate a single word programatically. Would anyone have a Python script that would let me do this using Google (or another) translation service? Thanks, Ken
4
10670
by: kovariadam | last post by:
Hi, Does anybody know why i get this error: SQL0176N The second, third or fourth argument of the TRANSLATE scalar function is incorrect. SQLSTATE=42815 with this query: SELECT TRANSLATE(p.meno, 'aaaaccdeeeiillnnoooorrsstuuuuyzzAAAACCDEEEIILLNNOOOORRSSTUUUUYZZ', 'ťئݬ') FROM oa.pracovnik p;
0
9932
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
10726
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10833
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10405
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9558
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7957
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7114
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5979
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3226
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.