GT1 file dump and disassembler

Using, learning, programming and modding the Gigatron and anything related.
Forum rules
Be nice. No drama.
Post Reply
User avatar
marcelk
Posts: 488
Joined: 13 May 2018, 08:26

GT1 file dump and disassembler

Post by marcelk »

I just cobbled together a simple GT1 hex dump tool: Utils/gt1dump.py

I made it to help debug the C compiler, but it does a pretty decent job to show the structure of any GT1 file.

Code: Select all

$ Utils/gt1dump.py Apps/WozMon_v2.gt1 
* file: Apps/WozMon_v2.gt1

0200  cd 0a 2a 2a 20 57 6f 7a  4d 6f 6e 00 2b 30 11 df  |..** WozMon.+0..|
0210  01 f6 2b 32 cd 60 e6 52  35 53 22 e3 32 2b 34 11  |..+2.`.R5S".2+4.|
0220  00 07 90 27 2b 34 11 00  08 2b 36 21 34 e9 e9 99  |...'+4...+6!4...|
0230  34 99 36 2b 36 11 e1 04  2b 22 21 2a 2b 24 21 32  |4.6+6...+"!*+$!2|
0240  2b 28 ec fe e3 06 2b 32  59 05 2b 34 21 36 7f 00  |+(....+2Y.+4!6..|
0250  5e 26 b4 cb 93 36 93 28  21 34 e6 01 35 4d 48 ee  |^&...6.(!4..5MH.|
0260  fe ff 2b 38 cd ad 1a 32  35 3f ac 11 e1 04 2b 22  |..+8...25?....+"|
0270  11 00 08 5e 32 99 32 35  53 7b 11 00 08 2b 32 2b  |...^2.25S{...+2+|
0280  28 5e 26 b4 cb 93 28 1a  28 8c a0 35 72 81 11 ee  |(^&...(.(..5r...|
0290  01 2b 34 21 34 ad e6 78  35 53 9d 8c 80 90 9f 8c  |.+4!4..x5S......|
02a0  08 f0 34 21 34 e6 02 2b  34 8c fe 35 72 91 ff 2b  |..4!4..+4..5r..+|
02b0  3a cd d9 75 2b 30 11 52  06 2b 22 21 30 b4 f5 e6  |:..u+0.R.+"!0...|
02c0  0a 35 50 c4 e3 07 e3 3a  cf 38 21 30 82 0f e6 0a  |.5P....:.8!0....|
02d0  35 50 d3 e3 07 e3 3a cf  38 63 ff 2b 3c 11 00 03  |5P....:.8c.+<...|
02e0  cf 18                                             |..|
* 226 bytes

0300  cd d3 75 59 80 2b 3e cf  3a 93 3e 21 3e ad 35 3f  |..uY.+>.:.>!>.5?|
0310  d1 e6 2e 35 50 07 35 72  1d 59 01 2b 40 90 07 e6  |...5P.5r.Y.+@...|
0320  0c 35 72 28 e6 01 2b 40  90 07 e6 18 35 72 31 cf  |.5r(..+@....5r1.|
0330  42 90 07 59 00 2b 30 2b  44 e9 e9 e9 e9 2b 34 21  |B..Y.+0+D....+4!|
0340  3e ad 93 3e e6 30 35 50  68 e6 0a 35 53 54 2b 30  |>..>.05Ph..5ST+0|
0350  e3 0a 99 34 90 35 e6 06  82 1f 35 56 68 e6 07 35  |...4.5....5Vh..5|
0360  53 68 2b 30 e3 10 99 34  90 35 21 30 35 3f cd 21  |Sh+0...4.5!05?.!|
0370  3e e6 02 2b 3e 21 40 35  53 84 21 44 f0 46 21 46  |>..+>!@5S.!D.F!F|
0380  e3 01 2b 46 90 07 35 72  91 cf 3a 21 44 2b 46 e6  |..+F..5r..:!D+F.|
0390  01 2b 42 21 42 b8 44 35  53 c7 21 42 e3 01 2b 42  |.+B!B.D5S.!B..+B|
03a0  82 07 35 72 a5 cf 3a 1a  32 35 72 ba 59 02 5e 32  |..5r..:.25r.Y.^2|
03b0  1a 43 cf 3c 1a 42 cf 3c  59 3a cf 38 21 32 e3 04  |.C.<.B.<Y:.8!2..|
03c0  2b 32 21 42 ad cf 3c 90  91 59 00 2b 40 90 07 59  |+2!B..<..Y.+@..Y|
03d0  5c cf 38 63 ff 2b 48 93  32 11 20 0f 2b 2a 5e 24  |\.8c.+H.2. .+*^$|
03e0  cf 3a 59 2a cf 38 21 30  ad 93 30 35 72 e2 11 00  |.:Y*.8!0..05r...|
03f0  04 cf 18                                          |...|
* 243 bytes

0400  59 81 2b 3e cf 3a 59 7f  5e 2b cf 38 2b 32 1a 0f  |Y.+>.:Y.^+.8+2..|
0410  2b 30 1a 0f f0 3e fc 30  35 72 1e 21 3e ad 90 0e  |+0...>.05r.!>...|
0420  21 3e ad 8c 0a 35 3f 60  8c 75 35 72 42 59 20 cf  |!>...5?`.u5rBY .|
0430  38 2b 32 1a 32 e6 06 35  50 40 5e 32 21 3e e6 01  |8+2.2..5P@^2!>..|
0440  2b 3e 90 04 e6 60 35 53  04 1a 32 8c 96 35 72 57  |+>...`5S..2..5rW|
0450  59 5c cf 38 11 00 04 cf  18 21 3e ad cf 38 93 3e  |Y\.8.....!>..8.>|
0460  90 04 f0 3e 2b 40 59 20  cf 38 59 0f 5e 2b cf 48  |...>+@Y .8Y.^+.H|
0470  90 fe                                             |..|
* 114 bytes

* start at $0200
I couldn't resist to add a disassemble option: -d. This will detect and disassemble vCPU instructions. Features include:
  • Resolve addresses for branch instructions
  • Convert SYS operand into Gigatron cycles
  • Show known zero page symbols
There is no intelligence in guessing if something is data or code: if a byte value is a vCPU opcode, it will disassemble it and its operand bytes. The only exception is that it doesn't attempt to disassemble data loaded in the zero page.

Little teaser:

Code: Select all

$ Utils/gt1dump.py -d Apps/Terminal.gt1
[... snip ...]
066a  59 20                    LDI   $20                |Y |
066c  5e 24                    ST    sysArgs            |^$|
066e  5e 25                    ST    sysArgs+1          |^%|
0670  11 e1 04                 LDWI  $04e1              |...|
0673  2b 22                    STW   sysFn              |+"|
0675  b4 cb                    SYS   134                |..|
0677  93 28                    INC   sysArgs+4          |.(|
0679  1a 28                    LD    sysArgs+4          |.(|
067b  8c a0                    XORI  $a0                |..|
067d  35 72 73                 BNE   $0675              |5rs|
[... etcetera ...]
It's so useful to me already, I don't understand why I didn't make this a year ago.
Post Reply