Jump to content
IGNORED

Atari_Ace's Blog - Dealer Demo, part 3: Dealing with symbols


RSS Bot

Recommended Posts

The last post walked through how to implement the basics of a disassembler, but we omitted several features to simplify the initial presentation. So let's fill in the omissions.

The main omission is the lack of a symbol table. I included a $names hash to hold the symbols and used it where needed, but there was no code to populate it. So let's fix that.

This code says we can get our symbols from the file we are slowly building up, 'dealerdemo.lst'.  It looks for assignments (e.g., '    =0000    FOO = $00'), and labels and put them into the name table, ignoring small values.

Now we need to hook this up.
     =0301      DUNIT = $0301     =0302      DCOMND = $0302     =0303      DSTATS = $0303     =0304      DBUFLO = $0304     =0305      DBUFHI = $0305     =0308      DBYTLO = $0308     =0309      DBYTHI = $0309     =030A      DAUX1 = $030A     =030B      DAUX2 = $030B                ;     =E459      SIOV = $E459
And rerun the disassembler to start seeing symbols appear.
sub read_img {  my ($addr, $size) = @_;  $addr = 0 if !defined $addr;  $size = 0x30 if !defined $size;  $addr = hex $addr;  my ($buff, $offset) = ('', 0);  $offset = 0x10 - 0x480 if $addr >= 0x480 && $addr < 0x500;  $buff = read_file('../../../atr/dealerdemo.atr', $size, $offset + $addr) if $offset != 0;  ($buff, $addr, length($buff));}
So we translate addresses between 0x480 and 0x500 to offsets into the atr file, rather than hard coding the offset, address and size as in v1.

Next, we need to add code to dump data.
The routines bytes and words chunks up bytes and words into groups of $count, and uses multi_buf to output them in listing format.  The routine get_label is an oversight from the last post, the disassembler should be able to put a label instead of 8 spaces before the opcode/directive if it has one handy.  Since we didn't populate the symbol table in the last post, the code wasn't yet needed, but now we should replace this line in print_op:
with this one:
Now let's hook up all the pieces.
 
We can now study the code and see that it simply calls SIOV with the READ ($52) command $F4 times, starting the buffer at ORIG, and incrementing it by $80 each time. So it loads sectors 2 up into 0xd00 to 0x8700, so let's add the following to read_img.
 
Attached File(s)
  • dd2.zip (3.08KB)
    Number of downloads: 0


http://atariage.com/forums/blog/734/entry-15006-dealer-demo-part-3-dealing-with-symbols/
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...