Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in 
CSDb User Forums


Forums > C64 Coding > ASM to C
2018-08-08 10:37
Mixer

Registered: Apr 2008
Posts: 278
ASM to C

Are there tools to convert a) disassembler output to some sort of C? b) macro assembler listings to C?

Such a thing can be done by substituting opcodes with their C-statement equals. Has anyone written more sophisticated tools for this?
 
... 5 posts hidden. Click here to view all posts....
 
2018-08-08 11:09
Mixer

Registered: Apr 2008
Posts: 278
My human mind is lazy. Any other 6502 decompilers in addition to IDA?
2018-08-08 11:16
iAN CooG

Registered: May 2002
Posts: 2050
by googling i found this, commercial
http://microapl.com/asm2c/index.html
it does 6502 to C
http://microapl.com/asm2c/sample6502.html
2018-08-11 20:09
Groepaz

Registered: Dec 2001
Posts: 8845
decompiling is a quite complex tasks - and most decompilers dont produce useful output. hexrays (IDA) is probably the best BY FAR and even its output is often quite a mess :)

that said, hexrays can do x86 and ARM - not 6502 :)

curious though what you'd want to use it for (that has 6502) - its not like such decompilers would magically produce C code from arbitrary assembler programs, it can only work *somewhat* when the assembler program is a compiled c program.
2018-08-12 00:32
Mixer

Registered: Apr 2008
Posts: 278
Groepaz, this is scene. Magical and impossible are our daily business :) Time to write a better tool. IAN's find is interesting and does seem to do pretty good job.
2018-08-12 00:41
Groepaz

Registered: Dec 2001
Posts: 8845
Quote:
Time to write a better tool.

some things just cant be done automatically - no matter how good the tool is.

some years ago i had the idiotic idea to make a basic v2 to C compiler... guess what, it cant be done either. you cant even convert the basic shit from the test/demo disk automatically :) with asm it will be even more impossible =P
2018-08-12 01:06
Mixer

Registered: Apr 2008
Posts: 278
You are probably correct, but I am not convinced yet. It does not have to be perfect. I am interested in the call structure of some complicated asm code, would like to see some asm math as c math.
2018-08-12 01:13
Groepaz

Registered: Dec 2001
Posts: 8845
for the call structure - use IDA. it can display assembly as flow-chart. THAT works pretty decent at least :) (you will need a "PRO" version, the normal one doesnt have 6502)
2018-08-12 07:30
oziphantom

Registered: Oct 2014
Posts: 227
I build this, which kind of does a thing. Needs more work, only tested on a couple of vsfs etc. I built it after I did most of the hard work on HM, but it helped. I will be visiting it before starting the next one.
https://github.com/oziphantom/CodeTree
It takes guesses at code structure and will tag, if/else, if chains etc.

I want it to be able to modify the regenerator config and add code-data blocks as it finds them, to remove the tediousness of it ;) I also want to be able to get a point where I can see what memory locations are read/written by functions. PRs welcome ;)

Note I don't really know Python so the code is not "pythony"
2018-08-12 07:33
oziphantom

Registered: Oct 2014
Posts: 227
Quote: for the call structure - use IDA. it can display assembly as flow-chart. THAT works pretty decent at least :) (you will need a "PRO" version, the normal one doesnt have 6502)

yeah but Maths is the neigh on impossible part

lda thing
clc
adc thing
sta thing

is trivial and a simple script will give you thing += thing its the
lda table,x
clc
adc otherTable,y
sta thing

you want converted and that is really hard to do, as you need to look at the tables and work out what the magic values are.
thing = x * 0.58 + y * 2.3 good luck..
2018-08-12 07:35
oziphantom

Registered: Oct 2014
Posts: 227
Quote: Quote:
Time to write a better tool.

some things just cant be done automatically - no matter how good the tool is.

some years ago i had the idiotic idea to make a basic v2 to C compiler... guess what, it cant be done either. you cant even convert the basic shit from the test/demo disk automatically :) with asm it will be even more impossible =P


What was the major blocker on basic to C? I would think it mostly has a 1:1 relationship. READ would be the tricky part. Making custom functions would probably need to be beyond scope, but what else?
Previous - 1 | 2 | 3 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Dr.Strange/Atlantis
hedning/G★P
Powerslave/Triad
Mythus/Delysid
DuncanTwain
sailor/Triad
Menace/Spaceballs
Jesper Madsen/Silver..
Markiz/Transcom
Toggle/Padua
Le Wurmling
ZeSmasher/F4CG
Guests online: 47
Top Demos
1 Uncensored  (9.7)
2 Comaland 100%  (9.7)
3 Edge of Disgrace  (9.7)
4 Coma Light 13  (9.6)
5 The Shores of Reflec..  (9.6)
6 Wonderland XII  (9.6)
7 Lunatico  (9.6)
8 We Come in Peace  (9.6)
9 Incoherent Nightmare  (9.5)
10 Wonderland XIII  (9.5)
Top onefile Demos
1 FMX Music Demo  (9.6)
2 Daah, Those Acid Pil..  (9.6)
3 Arok 20 Invitation  (9.6)
4 Merry Xmas 2017  (9.5)
5 Pandemoniac Part 2 o..  (9.5)
6 Party Horse  (9.4)
7 Dawnfall V1.1  (9.4)
8 In Memoriam BHF  (9.4)
9 Dawnfall  (9.4)
10 Synthesis  (9.4)
Top Groups
1 Oxyron  (9.4)
2 Booze Design  (9.4)
3 Censor Design  (9.4)
4 Finnish Gold  (9.3)
5 Crest  (9.3)
Top Diskmag Editors
1 Jazzcat  (9.6)
2 Newscopy  (9.4)
3 Peter  (9.3)
4 A Life in Hell  (9.2)
5 Antichrist  (9.0)

Home - Disclaimer
Copyright © No Name 2001-2018
Page generated in: 0.06 sec.