Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI Z80 => Topic started by: Matrefeytontias on June 08, 2012, 12:58:33 pm

Title: Prog2hex, the first on-calc Axe unsquisher
Post by: Matrefeytontias on June 08, 2012, 12:58:33 pm
Hi guys !

I wrote a simple on-calc unsquisher in Axe, which can unsquish any 8xp compiled ASM program into his hex translation ! Here is a screenie of it working by unsquishing ZPROT and executing the unsquished version (protecting the program in Str0) :

(http://mattias.refeyton.fr/espace-ti/prog2hex.gif)


But as you can see at the end of the screenie, and due to Axe bugs, you must archive all your stuffs on your calculator and clear the RAM manually to be able to use your calc normally afterwards ! (I'm not responsible ;D )
Problem solved ! Thanks to Runer112.

You can download it here (it's only 528 508 bytes in Noshell !) : http://mattias.refeyton.fr/espace-ti/PROG2HEX.zip (link updated)

Please comment ;)
Title: Re: Prog2hex, the first on-calc Axe disassembler
Post by: Nick on June 08, 2012, 01:06:05 pm
nice ö can't you make it that it translates those hex'es to their appropriate command? that would be great, because i don't know many users know all the hex things xp

but it's really cool, although it should be possible to remove the RAM clear glitch, have you any clue what causes the must-reset-thing?
Title: Re: Prog2hex, the first on-calc Axe disassembler
Post by: Matrefeytontias on June 08, 2012, 01:08:23 pm
I did much research, and anything I found is that's an Axe bug, so I don't know what to do to resolve it :'(

And an hex decompiler is a reaaaaaally hard thing to do :banghead: I'm not sure that I'll do it, since there are lots of it for computer. But who knows ...
Title: Re: Prog2hex, the first on-calc Axe disassembler
Post by: aeTIos on June 08, 2012, 02:14:45 pm
Hmm... I should look over it sometime, pretty sure I can track the problem.
Title: Re: Prog2hex, the first on-calc Axe disassembler
Post by: Runer112 on June 08, 2012, 02:20:42 pm
Doing a bit of disassembly of my own, I discovered how your program was corrupting RAM! And it's not a fatal Axe bug, so it's easily fixable. :)

When you initially create the output program, you store its size to C. You then use this as the loop variable for converting the input program to hexadecimal, but this is a problem because you convert one byte of binary data into two bytes of hexadecimal data per iteration. This results in the conversion loop converting about twice the amount of data that it should, corrupting an amount of RAM approximately equal to twice the size of the input program! :o

This is easy to fix though, and it even optimizes the program in the process! Just change the line that looks like this:
!If GetCalc(Str0P,{P-2}r*2-2→C)→H
To this:
!If GetCalc(Str0P,{P-2}r-1→C*2)→H
And then delete the C++ before the conversion loop and it should work as intended. :)
Title: Re: Prog2hex, the first on-calc Axe disassembler
Post by: aeTIos on June 08, 2012, 02:22:19 pm
Uh, lol. That was faster than I could ever do it.
Also runer optimize it :P
Title: Re: Prog2hex, the first on-calc Axe disassembler
Post by: Matrefeytontias on June 08, 2012, 03:13:49 pm
Thank you Runer for the solving :) (what a stupid error, I never noticed it <_< )

I'll try to optimize it myself, even I don't see much things too optimize right now =/

EDIT : the link is updated with the safe version :thumbsup:
Title: Re: Prog2hex, the first on-calc Axe disassembler
Post by: TIfanx1999 on June 09, 2012, 11:23:18 am
Pretty cool stuff there Matrefeytontias, nice work! ^^
Title: Re: Prog2hex, the first on-calc Axe disassembler
Post by: Matrefeytontias on June 09, 2012, 11:24:05 am
Thanks :)
Title: Re: Prog2hex, the first on-calc Axe disassembler
Post by: Stefan Bauwens on June 09, 2012, 02:23:10 pm
So if you use a computer hex-to-command program, you can actually retrieve the original basic source of a program you may have lost, and still had a compiled version of it?
If so, many people who lost their source will be very happy I think. :)
Title: Re: Prog2hex, the first on-calc Axe disassembler
Post by: Matrefeytontias on June 10, 2012, 10:16:31 am
Yeah, that's an use of it :) it can be really helpful if people loose their ASM source but keep their compiled version.
Title: Re: Prog2hex, the first on-calc Axe disassembler
Post by: aeTIos on June 10, 2012, 10:18:13 am
^
But it won't help if you lose your Axe source D:
Title: Re: Prog2hex, the first on-calc Axe disassembler
Post by: Matrefeytontias on June 10, 2012, 10:37:57 am
Yeah, I haven't done any hex -> Axe disassembler yet ;D

EDIT : link updated with a zip containing a smaller version and a readme.
Title: Re: Prog2hex, the first on-calc Axe disassembler
Post by: Nick on June 10, 2012, 10:42:41 am
is it even possible to dissassemble to axe or to convert hex to axe? since there are several ways to reach the same result in compiled code i think, so it would be hard to have the exact code, isn't it?
Title: Re: Prog2hex, the first on-calc Axe disassembler
Post by: Matrefeytontias on June 10, 2012, 10:45:19 am
I think it's impossible, that's too difficult ...

But thanks to my own disassembler, I disassembled little Axe programs containing only one routine, so I saw how several functions were working :)
Title: Re: Prog2hex, the first on-calc Axe disassembler
Post by: Nick on June 10, 2012, 10:47:11 am
nice :)

to convert the hex to asm you could always ask xeda.. that's like a walking asm (hex) dictionary xp
Title: Re: Prog2hex, the first on-calc Axe disassembler
Post by: Matrefeytontias on June 10, 2012, 10:47:58 am
Or you can also use an hex to ASM disassembler, there are many on the net.
Title: Re: Prog2hex, the first on-calc Axe disassembler
Post by: thepenguin77 on June 10, 2012, 01:50:25 pm
Just going to point out, this isn't actually a disassembler and it's not for axe. (I was really excited for a second)

An Axe decompiler would turn an executable program into it's original axe source code.
A disassembler would turn an executable program into z80 assembly. (i.e. bcall(_clrLCDFull) \ ld a, 5)
This is an unsquisher and simply takes the hex and returns an ASCII representation of it.

But, other than that, looks good. I like that it throws the AsmPrgm token out front.
Title: Re: Prog2hex, the first on-calc Axe disassembler
Post by: Matrefeytontias on June 10, 2012, 01:59:08 pm
Yeah, you're right, I changed the topic title, thank you :)