Re: A83: 83 Disassembler


[Prev][Next][Index][Thread]

Re: A83: 83 Disassembler




In accordance with the prophecy, Scott Dial uttered:


> There is still problems with that. If I put one byte of data between a
> routine then the rest of the code would be disassembled incorrectly.

> routine1:
>     ld a,3
>     ret
> .db $FE
> routine2:
>     ld a,4
>     ret

> would be disassembled as:

>     ld a,4
>     ret

>     cp $3E
>     inc b
>     ret

Yes. That is ye oldė disassemblerė problem. One way of solving it is using n
columns of disassembly, where n is the maximum number of bytes each
instruction may consist of. Like this:

(from your example)

0000: 3e ld a,3
0001: 03 ---
0002: c9 ret
0003: fe cp 3eh
0004: 3e ---
0005: 04 inc b
0006: c9 ret

At every blank line, add an alternative instruction in the next column:

0000: 3e ld a,3
0001: 03 ----------> inc bc
0002: c9 ret
0003: fe cp 3eh
0004: 3e ----------> ld a,4
0005: 04 inc b       ---
0006: c9 ret

The dashes below ld a,4 indicate that the ld instruction occupies 2 bytes.

When you start to look at your disasm dump, you follow the instructions
starting with ld a,3 and going downwards. The instructions in the right
column are not of interest. However, when you encounter a call to address
0004, you start at the ld a,4 instruction. You continue downwards in the
column, and when you reach an empty line (no dashes), you fall back to the
previous column (i.e. to the ret instruction). When an instruction accesses
(0003) as data, you can easily find the data in the byte column.

Linus

   - Linus Akesson ------------------------- http://linusworld.cjb.net -
   ::: :::. :.:: :. ::.. : :... ::.: ::. :::: :.:. :: :..: :.. :.: :....

Lewis's Law of Travel:
The first piece of luggage out of the chute doesn't belong to anyone, ever.




References: