cosarara.me

The blog

Disassembling bytecode

Today I rewrote the decompiler in Red Alien. Here is a quick comparison:

From script source:

#dyn 0x800000

#org @start
lock
:label
loadpointer @text
jump :label

#org @text
= \c\h01\h05\v\h01I don't even know what\n
= I'm doing! Ádudududu\p
= \c\h01\03Does this text even make\n
= sense?

Before:

'--------------------
'file name = /home/jaume/RH/ruby.gba
'address = 0x800000
'---

#org 0x800000
lock
loadpointer 0x880001a
jump 0x8800001

#org 0x80001a
= \cÀÈ\vÀI don't even know what\nI'm doing! Ádudududu\p\cÀ03Does this text even ma
= ke\nsense?

#org 0x800001
loadpointer 0x880001a
jump 0x8800001

After:

'--------------------
'file name =  /home/jaume/RH/ruby.gba
'address =  0x800000
'--------------------

#org 0x800000
lock
' joined
#org 0x800001
loadpointer 0x880001a
jump 0x8800001

#org 0x80001a
= \c\h01\h05\v\h01I don't even know what\nI'm doing! Ádudududu\p\c\h01\ha13Does 
= this text even make\nsense?$$

Notice how the code at 0x800001 isn't duplicated any more. Also, the splitting code for strings is now much better, and characters outside the ascii range are detected as control codes depending on the preceding characters (\c, \v). That $$ is the 0xFF string terminator, which I made explicit in August.

...and I spent just as much time getting backtick code blocks with PKS highlighting working on this blogpost than on the work itself.

- cosarara