LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-26-2005, 03:08 PM   #1
Yoyo302
Member
 
Registered: Jun 2005
Distribution: Gentoo
Posts: 36

Rep: Reputation: 15
asembler to c?


hi,
few days ago i've found some old programs whitch i wrote when i was starting programing in c, now i want to look into them, but i don't have sources. i disasembeled them and now i have some sources in asm.
unfortunetly i don't know asembler so i have a question, is there any posibility to translate thos sources in asembler into c or c ++ source file?

thx for all help.
 
Old 10-26-2005, 03:12 PM   #2
lowpro2k3
Member
 
Registered: Oct 2003
Location: Canada
Distribution: Slackware
Posts: 340

Rep: Reputation: 30
From what I've heard, its possible, but you might not be too happy with the source code you get
 
Old 10-26-2005, 04:13 PM   #3
Yoyo302
Member
 
Registered: Jun 2005
Distribution: Gentoo
Posts: 36

Original Poster
Rep: Reputation: 15
i know i could be changed, but i want to know how to translate it...
 
Old 10-26-2005, 05:04 PM   #4
Ian D
Member
 
Registered: Aug 2005
Location: Solihull, UK
Distribution: Fedora 39
Posts: 215

Rep: Reputation: 18
The problem is that the original compiler took your code and converted it into machine code (I hesitate to use the term 'assembler'), and it quite likely optimised it. If it saw that you had a for loop for example, and that the variable (lets call it 'i') was only used inside the loop, it might not bother with 'real storage' for i, but use a register. So long as the program works, you don't care.
To work backwards, what you would really need to do is to write some sample code and then see what code gets generated. If you have a variable called c and you write c++;, what code will get generated. With some study, you will get to regognise the pattern that represents the use of the ++ operator - and the same goes for everything else.
Of course, unless your program was compiled with all the debug information, you will not have any variable names, so you have to guess at what is going on.
I have decompiled programs in the past (when computers had fewer, more powerful commands - which made it easier) and you have to step through to get the feel for what the code is doing.

<JOKE> Someone once told me that C is a write only language. You write your program, and if it doesn't work, you tear it up and trry again, because no-one can read a C program.</JOKE> Seriously, unless your program holds the secret of life, tear it up and start again.

Ian
 
Old 10-27-2005, 12:08 AM   #5
Yoyo302
Member
 
Registered: Jun 2005
Distribution: Gentoo
Posts: 36

Original Poster
Rep: Reputation: 15
ok, thx, i'll try
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration