Author Topic: PRIZM Disassembler  (Read 34292 times)

0 Members and 1 Guest are viewing this topic.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
PRIZM Disassembler
« on: January 16, 2011, 07:34:40 am »
I just made a GUI Disassembler for the Casio Prizm, the first GUI disassembler for the Prizm actually  :w00t:

Below is a link for the setup.exe for Windows Users, but also the .pyw file for Linux/Mac OS users or even Windows Users looking for portability. Whoever decides to use this .pyw file will need Python and wxPython installed in their computers.

What can I say? I'll try to release a new version as soon as possible with an About Box, a Link to Omnimaga Forums and Support for reading .g3a files. All these 3 features are really easy to make, but I just don't have the time at the moment.

The source code may be public, but any release on the Net without my authorization is not allowed.

Also, this is a disassembler, not a detokenizer, so only Assembly files are supported.

But it's also quite good to have a Disassembler (even though it is quite basic) a few days after the Prizm was released.

Downloads:


Setup - http://www.megaupload.com/?d=T76Q1EK0
.exe - www.davidgom.co.cc/PrizmDisassembler.zip

Sorry for megaupload link, but I can't host it at my website at the moment, only the .zip. Would I be able to upload it to Omnimaga Downloads, though?

EDIT: I really recommend the .pyw file (install Python 2.6 and wxPython), it's much faster than the others.

EDIT 2: I really forgot to, but special thanks to JosJuice, for helping me with databases, no About Box in this version, but in the next one you'll be credited.
« Last Edit: January 16, 2011, 07:53:24 am by ScoutDavid »

Offline jnesselr

  • King Graphmastur
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2270
  • Rating: +81/-20
  • TAO == epic
    • View Profile
Re: PRIZM Disassembler
« Reply #1 on: January 16, 2011, 08:58:44 am »
YOu didn't mention at all about xlrd.  Can you not do this without some excel database? (If memory serves, that is what xlrd does)

Offline alberthrocks

  • Moderator
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 876
  • Rating: +103/-10
    • View Profile
Re: PRIZM Disassembler
« Reply #2 on: January 16, 2011, 09:34:08 am »
YOu didn't mention at all about xlrd.  Can you not do this without some excel database? (If memory serves, that is what xlrd does)

Agreed - running this in Ubuntu gives:
Code: [Select]
~/TICalc$ python Prizm*
Traceback (most recent call last):
  File "Prizm Disassembler.pyw", line 3, in <module>
    import xlrd
ImportError: No module named xlrd
~/TICalc$

A suggestion is to use a "dictionary" to do all of the matching.
http://tibasicdev.wikidot.com/forum/t-184793/python-ti83-basic-converter

Also, Undo/Redo doesn't work.

Finally... if you make a disassembler, one of the usual practices is to make it CLI only as not everyone wants a GUI tacked on. (I love wxPython, but it takes a nasty amount of space... :P)
Withgusto Networks Founder and Administrator
Main Server Status: http://withg.org/status/
Backup Server Status: Not available
Backup 2/MC Server Status: http://mc.withg.org/status/


Proud member of ClrHome!

Miss my old signature? Here it is!
Spoiler For Signature:
Alternate "New" IRC post notification bot (Newy) down? Go here to reset it! http://withg.org/albert/cpuhero/

Withgusto Networks Founder and Administrator
Main Server Status: http://withg.org/status/
Backup Server Status: Not available
Backup 2/MC Server Status: http://mc.withg.org/status/

Activity remains limited due to busyness from school et al. Sorry! :( Feel free to PM, email, or if you know me well enough, FB me if you have a question/concern. :)

Don't expect me to be online 24/7 until summer. Contact me via FB if you feel it's urgent.


Proud member of ClrHome!

Spoiler For "My Projects! :D":
Projects:

Computer/Web/IRC Projects:
C______c: 0% done (Doing planning and trying to not forget it :P)
A_____m: 40% done (Need to develop a sophisticated process queue, and a pretty web GUI)
AtomBot v3.0: 0% done (Planning stage, may do a litmus test of developer wants in the future)
IdeaFrenzy: 0% done (Planning and trying to not forget it :P)
wxWabbitemu: 40% done (NEED MOAR FEATURES :P)

Calculator Projects:
M__ C_____ (an A____ _____ clone): 0% done (Need to figure out physics and Axe)
C2I: 0% done (planning, checking the demand for it, and dreaming :P)

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: PRIZM Disassembler
« Reply #3 on: January 16, 2011, 04:15:56 pm »
Oh sorry, that was from Assemblex code, just remove it. Sorry :S You can edit the code! Right Click>>Edit.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: PRIZM Disassembler
« Reply #4 on: January 16, 2011, 05:34:48 pm »
Update: Fixed a little bugs.

Code: [Select]
def getG3Adata(event):
dlg = wx.FileDialog(self, "Choose a file", self.dirname, "", 'g3a Files (*.g3a)|*.g3a', wx.OPEN)
if dlg.ShowModal() == wx.ID_OK:
self.filename=dlg.GetFilename()
self.dirname=dlg.GetDirectory()

# Open the file, read the contents and set them into
# the text edit window
filehandle=open(os.path.join(self.dirname, self.filename),'r')
filehandle.close()

self.SetTitle('Assemblex - '+self.filename)

hexvalues = open(self.filename, "rb").read().encode("hex")
hexProgram = fill(hexvalues,16)

hexProgramData = hexProgram[28672:(len(hexProgram)-4)]
hexProgramUpperData = hexProgramData.upper()

self.inputText.SetValue(self.inputText.GetValue() + hexProgramUpperData)

Is this OK for reading .g3a files? I'm not sure about the size of header, but I think it is $7000, or 28672. Is that right?
Thanks

Offline JosJuice

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1344
  • Rating: +66/-14
    • View Profile
Re: PRIZM Disassembler
« Reply #5 on: January 17, 2011, 01:29:34 am »
Yes, the header is $7000 bytes large. There's also a four-byte area at the very end of the file that you should skip.

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: PRIZM Disassembler
« Reply #6 on: January 17, 2011, 01:43:01 am »
Sorry about multiple posts ahead of time, if there are any. I'm just going to lump everything together in one post:

1) BSL, I think there's a problem with branch adresses in your disassembler. It keeps jumping to the middle of Longwords.

2) I finally got my Prizm today and my god are the math functions fast. I couldn't even measure the time of individual functions(they took less than a sec on 1000 iteration loops) and the integral function is 3-4x faster than a TI-84+ SE with a really complicated equation. I see a ton of potential in the platform if we get something like Axe built.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline z80man

  • Casio Traitor
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 977
  • Rating: +85/-3
    • View Profile
Re: PRIZM Disassembler
« Reply #7 on: January 17, 2011, 01:50:37 am »
Sorry about multiple posts ahead of time, if there are any. I'm just going to lump everything together in one post:

1) BSL, I think there's a problem with branch adresses in your disassembler. It keeps jumping to the middle of Longwords.

2) I finally got my Prizm today and my god are the math functions fast. I couldn't even measure the time of individual functions(they took less than a sec on 1000 iteration loops) and the integral function is 3-4x faster than a TI-84+ SE with a really complicated equation. I see a ton of potential in the platform if we get something like Axe built.
I think your right with this potential. Although the ARM on the nspire can reach higher clock speeds than the SH3 some instructions, such as division, can take over 100 clock cycles while the SH3 and its RISC architecture can do the same instruction in only one cycle.

List of stuff I need to do before September:
1. Finish the Emulator of the Casio Prizm (in active development)
2. Finish the the SH3 asm IDE/assembler/linker program (in active development)
3. Create a partial Java virtual machine  for the Prizm (not started)
4. Create Axe for the Prizm with an Axe legacy mode (in planning phase)
5. Develop a large set of C and asm libraries for the Prizm (some progress)
6. Create an emulator of the 83+ for the Prizm (not started)
7. Create a well polished game that showcases the ability of the Casio Prizm (not started)

Offline bsl

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 157
  • Rating: +14/-0
    • View Profile
Re: PRIZM Disassembler
« Reply #8 on: January 17, 2011, 02:08:39 am »
Sorry about multiple posts ahead of time, if there are any. I'm just going to lump everything together in one post:
1) BSL, I think there's a problem with branch adresses in your disassembler. It keeps jumping to the middle of Longwords.
Yes, I know - I am fixing that now: Both the data movement and branch instructions, the rest look good.
I may add data references so that the disassembler skips over this as data.
I might add more command line options too.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: PRIZM Disassembler
« Reply #9 on: January 17, 2011, 07:37:30 am »
Yes, the header is $7000 bytes large. There's also a four-byte area at the very end of the file that you should skip.

Then I'm almost releasing a file that reads .g3a files. .g3a files are the only Assembly ones? If there are more I'd like to make my disassembler support them :D

Also, anybody already tried disassembling OSs and stuff on my Disassembler?

Offline JosJuice

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1344
  • Rating: +66/-14
    • View Profile
Re: PRIZM Disassembler
« Reply #10 on: January 17, 2011, 08:52:19 am »
.g3a files are the only files that contain assembly code, with the exception of OS update files. No OS update files have been released, so we don't know anything about that file type. We haven't been able to dump the OS from the calc either.

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: PRIZM Disassembler
« Reply #11 on: January 17, 2011, 09:14:23 am »
Sorry about multiple posts ahead of time, if there are any. I'm just going to lump everything together in one post:

1) BSL, I think there's a problem with branch adresses in your disassembler. It keeps jumping to the middle of Longwords.

2) I finally got my Prizm today and my god are the math functions fast. I couldn't even measure the time of individual functions(they took less than a sec on 1000 iteration loops) and the integral function is 3-4x faster than a TI-84+ SE with a really complicated equation. I see a ton of potential in the platform if we get something like Axe built.
I think your right with this potential. Although the ARM on the nspire can reach higher clock speeds than the SH3 some instructions, such as division, can take over 100 clock cycles while the SH3 and its RISC architecture can do the same instruction in only one cycle.
Actually, the division instruction on the SH3 only divides 1 bit. To divide a 32-bit number, you have to execute the instruction 32 times. Dividing 1 bit in ARM takes about 3 cycles, I think (since it doesn't have a dedicated instruction for it). It's not such a huge difference.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: PRIZM Disassembler
« Reply #12 on: January 17, 2011, 09:16:42 am »
http://pastebin.com/vA5yVgj5

My disassembler reads this as the Hexadecimal code of Convert.g3a. Hum, the function is the following:

Code: [Select]
def getG3Adata(event):
dlg = wx.FileDialog(self, "Choose a file", self.dirname, "", 'g3a Files (*.g3a)|*.g3a', wx.OPEN)
if dlg.ShowModal() == wx.ID_OK:
self.filename=dlg.GetFilename()
self.dirname=dlg.GetDirectory()

# Open the file, read the contents and set them into
# the text edit window
filehandle=open(os.path.join(self.dirname, self.filename),'r')
filehandle.close()

self.SetTitle('PRIZM Disassembler - '+self.filename)

hexvalues = open(self.filename, "rb").read().encode("hex")
hexProgram = fill(hexvalues,16)

hexProgramData = hexProgram[57344:(len(hexProgram)-4)]

self.inputText.SetValue(self.inputText.GetValue() + hexProgramData)

Is it correct? Any ideas?
« Last Edit: January 17, 2011, 09:19:32 am by ScoutDavid »

Offline bsl

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 157
  • Rating: +14/-0
    • View Profile
Re: PRIZM Disassembler
« Reply #13 on: January 17, 2011, 10:50:49 pm »
Here is version 002 of the command line disassembler.
Fixed the data transfer and branch instructions, also included data and code references during
disassemby, thanks to python's dictionary [or hash in perl].
To disassemble a whole file: c:\> sh3_disass.py Geometry.g3a  7000 >  Geometry.S
To disassemble in a range:   c:\> sh3_disass.py Geometry.g3a  7000 7100 >  Geometry_7000_7100.S
Here is an example of the output:
Code: [Select]
00007000: MOV.L R14,@-R15
00007002: STS.L PR,@-R15
00007004: ADD $FC,R15
00007006: MOV.L R4,@R15
00007008: MOV.L @($07*4+PC),R3 = #00300034
0000700A: JSR @R3
0000700C: MOV R5, R14
0000700E: MOV.L @($07*4+PC),R1 = #0038DF00
00007010: MOV $01, R6
00007012: MOV $00, R4
00007014: JSR @R1
00007016: MOV R6, R5
00007018: MOV.L @($05*4+PC),R7 = #0033767C
0000701A: EXTU.W R14,R5
0000701C: MOV.L @R15,R4
0000701E: ADD $04,R15
00007020: LDS.L @R15+,PR
00007022: JMP @R7
00007024: MOV.L @R15+,R14
00007026: 0000 ?
00007028: .data 00300034 dword ref:7008
0000702C: .data 0038df00 dword ref:700E
00007030: .data 0033767c dword ref:7018
00007034: MOV.L @($0D*4+PC),R7 = #0038FE4C
00007036: MOV $00, R6
00007038: MOV.L @($0D*4+PC),R4 = #0038FE50
0000703A: BRA $7042
0000703C: MOV.L @R7,R2
0000703E: MOV.L R6,@R2
00007040: ADD $04,R2
00007042:                 ;code ref: 703A
00007042: MOV.L @R4,R5
00007044: CMP/HS R5,R2

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: PRIZM Disassembler
« Reply #14 on: January 18, 2011, 12:53:34 am »
Nice stuff!