Learning how to decompile .o files

Discuss anything ZDoom-related that doesn't fall into one of the other categories.

Learning how to decompile .o files

Postby Cjk10000 » Sat Jun 09, 2012 10:36 pm

One problem that people are probably running into is that with new zdoom functions getting added, older decompilers (like ListACS) that work for the new zdoom features don't work anymore, or pretty much break if one unknown function comes along.

I compiled something in a new format and seemed to have misplaced the source somehow. Ideally I'd like to get it back by decompiling-- luckily in my case it was just a few lines of ACS code... but if it was much larger I'd have been out of luck.

I can't find anywhere on documentation for reading the bytecode itself. I checked the Hexen specs to see if I could get a headstart, but it just tells you stuff that a programmer already knows/can infer easily. Ideally the plan was to find a file like the Unofficial Doom Specs file which tells you in detail the purpose of the bytes and how to extrapolate usable data from them.
Is there anyway to find documentation on how to read the compiled bytecode? I read somewhere that Randy pretty much redid ACS so I assume the newer ACS may potentially be completely different from Hexen scripts.
User avatar
Cjk10000
 
Joined: 02 Jan 2009

Re: Learning how to decompile .o files

Postby Nash » Sat Jun 09, 2012 11:08 pm

It's unfortunate that you lost your source but it's better to have backups handy. Even sending the source to your own e-mail address is better than absolutely no backups...
User avatar
Nash
http://twitter.com/ISurvivorGame
 
Joined: 27 Oct 2003
Location: Kuala Lumpur, Malaysia

Re: Learning how to decompile .o files

Postby Blzut3 » Sun Jun 10, 2012 3:03 am

Cjk10000 wrote:Is there anyway to find documentation on how to read the compiled bytecode? I read somewhere that Randy pretty much redid ACS so I assume the newer ACS may potentially be completely different from Hexen scripts.

Here you go.
Blzut3
Pronounced: B-l-zut
 
Joined: 24 Nov 2004

Re: Learning how to decompile .o files

Postby Cjk10000 » Sun Jun 10, 2012 2:28 pm

Blzut3 wrote:
Cjk10000 wrote:Is there anyway to find documentation on how to read the compiled bytecode? I read somewhere that Randy pretty much redid ACS so I assume the newer ACS may potentially be completely different from Hexen scripts.

Here you go.


That is awesome! Thanks :)

If you don't mind me ninja'ing a question in here:
How does zdoom handle multiple scripts with respect to stacks? Does it have a separate stack for every script run? Always wondered how it also determines which ones to run...etc
So far I've read over the entire manual, that's pretty much the last part I'm trying to figure out (besides getting the blocks like if/while/switch to be read correctly)
User avatar
Cjk10000
 
Joined: 02 Jan 2009

Re: Learning how to decompile .o files

Postby Blzut3 » Sun Jun 10, 2012 3:28 pm

Cjk10000 wrote:How does zdoom handle multiple scripts with respect to stacks? Does it have a separate stack for every script run? Always wondered how it also determines which ones to run...etc

While scripts should be seen as executing simultaneously with no particular order (much like threads) they are technically executed in some undefined order one by one until either a terminate or delay instruction is reached. The stack pointer is zeroed between scripts, but in theory it should always be 0 after the execution of such instruction.
Blzut3
Pronounced: B-l-zut
 
Joined: 24 Nov 2004

Re: Learning how to decompile .o files

Postby Gez » Sun Jun 10, 2012 3:35 pm

The order is not undefined actually, since it has been subjected to a hidden compatibility option to run vanilla Hexen map in the reverse order of what ZDoom does. Or I'm being confused.
Gez
 
Joined: 06 Jul 2007

Re: Learning how to decompile .o files

Postby Blzut3 » Sun Jun 10, 2012 3:41 pm

Gez wrote:The order is not undefined actually, since it has been subjected to a hidden compatibility option to run vanilla Hexen map in the reverse order of what ZDoom does. Or I'm being confused.

The order in which the scripts execute are undefined. That compatibility option changes the preference when loading multiple scripts with the same number IIRC.
Blzut3
Pronounced: B-l-zut
 
Joined: 24 Nov 2004

Re: Learning how to decompile .o files

Postby Worst » Mon Jun 11, 2012 12:49 pm

Blzut3 wrote:That compatibility option changes the preference when loading multiple scripts with the same number IIRC.

How would you load multiple scripts with the same number in vanilla hexen? There is no library support, so in order for that to happen, you'd need two scripts with the same number, within the same behaviour lump.. at which point I think ACC would have yelled at anyone trying that.

There is a compability check that reverses the order in which scripts executed during the same tic are run.
http://www.zdoom.org/Changelog/1565/files
Worst
 
Joined: 28 Apr 2007
Location: finland

Re: Learning how to decompile .o files

Postby Blzut3 » Mon Jun 11, 2012 4:03 pm

Worst wrote:How would you load multiple scripts with the same number in vanilla hexen? There is no library support, so in order for that to happen, you'd need two scripts with the same number, within the same behaviour lump.. at which point I think ACC would have yelled at anyone trying that.

If you use "think" and "ACC" in the same sentence you're probably wrong. :p viewtopic.php?f=7&t=25065&p=480643
Worst wrote:There is a compability check that reverses the order in which scripts executed during the same tic are run.
http://www.zdoom.org/Changelog/1565/files

I see. Regardless though, it isn't safe to assume any order if you want maximum compatibility between VMs. (Yes there is another port non-ZDoom based getting support for ZDoom's ACS.) Since it's not a safe assumption it can be said to be undefined.
Blzut3
Pronounced: B-l-zut
 
Joined: 24 Nov 2004

Re: Learning how to decompile .o files

Postby Graf Zahl » Mon Jun 11, 2012 5:07 pm

It may be undefined but any port implementing ACS should be aware of this - or it may get problems with some maps.
User avatar
Graf Zahl
 
Joined: 19 Jul 2003
Location: Germany

Re: Learning how to decompile .o files

Postby Cjk10000 » Mon Jun 11, 2012 9:56 pm

Blzut3 wrote:(Yes there is another port non-ZDoom based getting support for ZDoom's ACS.)


Cool, which one is that? :D
User avatar
Cjk10000
 
Joined: 02 Jan 2009

Re: Learning how to decompile .o files

Postby Blzut3 » Mon Jun 11, 2012 10:50 pm

Cjk10000 wrote:Cool, which one is that? :D

Eternity Engine
Blzut3
Pronounced: B-l-zut
 
Joined: 24 Nov 2004


Return to General

Who is online

Users browsing this forum: BurntApples and 3 guests