Previous in Forum: Sound Driver?   Next in Forum: Scheduling n jobs on m machines software
Close
Close
Close
14 comments
Rate Comments: Nested
Power-User

Join Date: Jun 2007
Location: ether
Posts: 371
Good Answers: 1

c to assembly

02/10/2008 5:26 AM

Hello everyone!

I would like to know if there is any program to translate C files into assembly language for any processor?

I am not a computer wis, so this ting would come very handy!

all for now

__________________
“For no man can forbid the spark nor tell whence it may come.” ? Francis Bacon
Register to Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.
Guru
Engineering Fields - Instrumentation Engineering - New Member Hobbies - Fishing - New Member

Join Date: Jan 2008
Location: Kazakhstan
Posts: 753
Good Answers: 8
#1

Re: c to assembly

02/10/2008 7:45 AM

Visit a corresponding link in wikipedia and you'll find that answer on your question is no.

Register to Reply
Guru
Popular Science - Biology - New Member Hobbies - Musician - New Member APIX Pilot Plant Design Project - Member - New Member Hobbies - CNC - New Member Fans of Old Computers - ZX-81 - New Member

Join Date: Jan 2007
Location: Centurion, South Africa
Posts: 3921
Good Answers: 97
#2

Re: c to assembly

02/10/2008 8:54 AM

You can compile the c code with the appropriate compiler and then disassemble the exe file.

__________________
Never do today what you can put of until tomorrow - Student motto
Register to Reply
Power-User

Join Date: Jun 2007
Location: ether
Posts: 371
Good Answers: 1
#3
In reply to #2

Re: c to assembly

02/10/2008 9:11 AM

Hello Hendrik!

That would give me the assembly for the program?

(is that in many text editors the simbols are not possible to be reproduced, correct?)

__________________
“For no man can forbid the spark nor tell whence it may come.” ? Francis Bacon
Register to Reply
Guru
Popular Science - Biology - New Member Hobbies - Musician - New Member APIX Pilot Plant Design Project - Member - New Member Hobbies - CNC - New Member Fans of Old Computers - ZX-81 - New Member

Join Date: Jan 2007
Location: Centurion, South Africa
Posts: 3921
Good Answers: 97
#6
In reply to #3

Re: c to assembly

02/11/2008 12:52 AM

Hi electronick

My understanding was processors in the same family.( x86 for example)

.

What I have done a lot of times is the following.

I wrote a program in Tubo Pascal (I like it because the compiler strips out unused library code).

Compile the program to EXE or COM file.

then I use a decompiler to convert it into assembler code and the code is piped to a text file.

Debug (still available in XP) can be used.

You then view the file and copy whatever you need.

Thinking about it you seem to want to have assembler code suitable for x86 and for example a PIC. That would be mostly impossible because the use a different approach. The PIC uses RISC code.

What possessors do you use?

What is your application?

In a lot of cases C compilers are available and it is even possible to create your own compiler.

__________________
Never do today what you can put of until tomorrow - Student motto
Register to Reply
Commentator

Join Date: Sep 2006
Location: Troy, NY
Posts: 86
Good Answers: 5
#4

Re: c to assembly

02/10/2008 11:00 AM

There is no easy way to convert a C program to (an even lower-level) assembly, and then also have it portable between various processors.

You would be better off writing a new program in assembly language.

Register to Reply
Active Contributor

Join Date: Nov 2007
Location: USA and Canada
Posts: 23
#5

Re: c to assembly

02/10/2008 11:28 PM

you need a c compilor.

__________________
Funny N.
Register to Reply
Guru

Join Date: May 2007
Location: Budapest, Hungary, HA5YAR
Posts: 617
Good Answers: 14
#7

Re: c to assembly

02/11/2008 1:13 AM

C language source code is not executable for processors so your C compiler translates it to a sequence of machine instruction according to the instruction set of the processor. If you load it with the good old "DEBUG" program you can list the executable program with assembly mnemonics.

__________________
Aged man is not old man...
Register to Reply
Guru
Popular Science - Weaponology - New Member Safety - ESD - New Member Hobbies - Fishing - New Member

Join Date: Sep 2006
Location: Near Frankfurt am Main, Germany. 50.390866N, 8.884827E
Posts: 17996
Good Answers: 200
#8

Re: c to assembly

02/11/2008 6:49 AM

Moving from a different style of processor to another is always fraught as although the core program will most probably work, all the input and output tasks probably won't! Even within the same family there are differences and these can be very difficult to identify and fix. Even going "up" a proccessor type (newer) means that the code will not be using all the better points of the new processor!!

The suggestion to go to an executable and then back into the language of the next processor is quite a good idea (I have personally never done it though!) as long as you can redo all the I/O as I mentioned before!! This could be quite a daunting task!!!

__________________
"What others say about you reveals more about them, than it does you." Anon.
Register to Reply
Guru
Engineering Fields - Instrumentation Engineering - New Member Hobbies - Fishing - New Member

Join Date: Jan 2008
Location: Kazakhstan
Posts: 753
Good Answers: 8
#9

Re: c to assembly

02/11/2008 9:58 AM

Hi everybody,

Once this question was posted at forum, i thought we were asked about some universal program for conversion c to assemble suitable for any processor. So my answ was - no. But after Hendrik reply I`ve seen absolutely new (at least for me) approach. All genius is simple! But who can explain me needs to do such complex conversions. It looks workable for the same platform. But why do we need having working good no matter pascal or c code to assemble one for the same platform? For further optimization?

For another platform we could be find and use cross-assembler. But this case I doubt that it (cross-assembled code) will be work smoothly.

For transfering to another platform source c code it would be more suitable to find appropriate compiler. So often existing compilers have embedded options to create code for several platforms.

Thanks

Register to Reply
Guru
Panama - Member - New Member Hobbies - CNC - New Member Engineering Fields - Marine Engineering - New Member Engineering Fields - Retired Engineers / Mentors - New Member

Join Date: Dec 2006
Location: Panama
Posts: 4273
Good Answers: 213
#10

Re: c to assembly

02/11/2008 10:39 AM

i write c code on my x386 machine, compile and get it running the way I want it (usually involving some sort of data link I/O). Then I take the program in text form and load it into another machine with it's own compiler (i.e., my Palm Tungsten E2). First attempt to run it, of course, gives me all sorts of errors, but it is relatively easy to identify the problem lines and rewrite these with the appropriate key words. Not elegant, but it works (I also generally write very small, task specific programs as the need arises- I don't know how effective my approach would be if I tried to incorporate all the eye candy that seems so important to programmers today). Mostly, I am trying to get information in to the computer for further analysis. I am not a computer wiss, either, and I would really like to find someone else to do the tedious work of programming, but I haven't found any commercial software that can solve my problems as quickly as I can by writing my own code.

Register to Reply
Guru
Engineering Fields - Instrumentation Engineering - New Member Hobbies - Fishing - New Member

Join Date: Jan 2008
Location: Kazakhstan
Posts: 753
Good Answers: 8
#11
In reply to #10

Re: c to assembly

02/11/2008 10:53 AM

Everything what can work is elegant at all. At least I know it has a practice point. Thanks again.

Register to Reply
Power-User

Join Date: Jan 2008
Location: Toronto, Canada
Posts: 302
Good Answers: 4
#12

Re: c to assembly

02/11/2008 5:26 PM

You don't need to convert C to assembly. You need a C complier for the processor you want the program to run at. There are probably C compliers for all available processors.

__________________
Pineapple
Register to Reply
Guru
Popular Science - Biology - New Member Hobbies - Musician - New Member APIX Pilot Plant Design Project - Member - New Member Hobbies - CNC - New Member Fans of Old Computers - ZX-81 - New Member

Join Date: Jan 2007
Location: Centurion, South Africa
Posts: 3921
Good Answers: 97
#13

Re: c to assembly

02/12/2008 3:08 AM

Hi electronick

I have seen it somewhere but I can't find it now. - You seem to have a PIC with a built in C compiler and you want to use the same code on other CPU's. Is it a compiler or an interpreter?

I last did PIC about 10 years ago (a bit rusty) without any fancy stuff,

There are C compilers (on x86 machines) available and you can set the output for a lot of PIC's. Enquire at the supplier. Microchip supply MPLAB as freeware (Assembler ide) and sells C compilers for the PIC.

Other people also sell C, Pascal and Basic compilers. look on the web there are bound to be free one out there.

I am a DEY (do everything myself) fanatic and would create my own compiler.

Please give some examples of the C code you need to port.

__________________
Never do today what you can put of until tomorrow - Student motto
Register to Reply
Power-User

Join Date: Jun 2007
Location: ether
Posts: 371
Good Answers: 1
#14
In reply to #13

Re: c to assembly

02/12/2008 1:18 PM

that will be both!

a intepreter and a compiler! that would depend on the microcontroller!(and the processor they use built in!)

I tink this could be a mega project for sourceforge, ehehe!

I tank your help and availability to translate my code ;

tow notes dough- I have a lot of libraries and I cannot pay for it- it would take a lot of work to you !

I can give you more details in private messages...

__________________
“For no man can forbid the spark nor tell whence it may come.” ? Francis Bacon
Register to Reply
Register to Reply 14 comments
Copy to Clipboard

Users who posted comments:

Andy Germany (1); caramba (3); coonj (1); cwarner7_11 (1); electronick (2); FunnyNYPD (1); Hendrik (3); Pineapple (1); Qqberci (1)

Previous in Forum: Sound Driver?   Next in Forum: Scheduling n jobs on m machines software

Advertisement