Jump to content

1

Atari_Ace's Blog



Dealer Demo, part 11: One Assembler to Rule them All

Posted by Atari_Ace, 14 September 2018 · 106 views
forth
We've now reached a compact bit of code in the Dealer Demo that provides an assembler to Forth.  And the assembler in Forth is a thing of beauty indeed.  Written by Bill Ragsdale (as was most of the Forth kernel), it provides an assembler that can produce surprisingly readable code without the use of labels.  In essence it implements high-...


Dealer Demo, part 10: A complete kernel

Posted by Atari_Ace, 14 September 2018 · 83 views

OK, let's finish off the kernel of Dealer Demo .
 
The next chunk is the COLD start routine, starting at $1C84, which is implemented as a primitive.  Following that are a variety of standard Forth words dealing with mathematical operations and buffer and screen management.  This leads up to TCIOV, a Dealer Demo primitive to invoke CIO rout...


Dealer Demo, part 9: Strings are things

Posted by Atari_Ace, 12 September 2018 · 83 views
forth
We continue with decompiling Dealer Demo at $ 175D, seeing -TRAILING, (.") (PDOTQ), and then a handful of words leading to the word ERROR which decompiles incorrectly.
 
Looking closely, we see that the .WORD PDOTQ precedes strings in the listing, which are represented as a count, followed by the string contents.  The code to decompile such a st...


Dealer Demo, part 8: Who compiles the compiler?

Posted by Atari_Ace, 08 September 2018 · 79 views

We pick up decompiling again at $148C, where we find 1+ (ONEP).  It is followed by 2+ (TWOP), HERE, ALLOT, , (COMMA), C, (CCOMM), - (SUB), = (EQUAL), > (GREAT), ROT, SPACE and -DUP (DDUP).  All of these are identical to the fig-Forth listing, which implements these as colon-definitions, which is expected.  Although SUB, EQUAL and ROT ar...


Dealer Demo, part 7: Forward is the new Back

Posted by Atari_Ace, 04 September 2018 · 97 views

Thus far in disassembling the Dealer Demo , we've run across primitive definitions that have a PFA of .WORD *+2 and then some 6502 assembly code.  There were two exceptions I didn't draw attention to at the time, the word 'I' and the word 'DROP'.  DROP's PFA was simply ".WORD POP", in other words it took advantage of the fact the POP falls into...


Dealer Demo, part 6: Less is More

Posted by Atari_Ace, 03 September 2018 · 92 views

We resume our disassembly of the Dealer Demo and find the next four Forth words, 0= and 0<, and then unexpectedly U< and <.-def  WORD     NFA   PFA    same as fig-Forth?10A7  0=       L605  ZEQU   Yes10BC  0<    ...


Dealer Demo, part 5: More Forth for you

Posted by Atari_Ace, 02 September 2018 · 90 views

In the last post I explained how the NEXT routine uses IP and W to JMP from word to word, but otherwise neglected to explain the Forth environment.  Let's remedy that.
 
Forth contains two stacks, a data stack and a return stack.
 
The 6502 stack pointer indexes the return stack in page one.  Saving and restoring the interpreter pointe...


Dealer Demo, part 4: Some Forth at last

Posted by Atari_Ace, 31 August 2018 · 90 views

So we spent the last two posts working on tooling to reverse engineer the Dealer Demo, and got the bootloader disassembled for study.  Now we can start disassembling the Forth kernel.  Let's start with "-dis d00 8":0D00: EA        ORIG    NOP0D01: 4C 8D 1C      ...


Dealer Demo, part 3: Dealing with symbols

Posted by Atari_Ace, 31 August 2018 · 105 views

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....


Dealer Demo part 2, Let's make a disassembler!

Posted by Atari_Ace, 28 August 2018 · 104 views

So to decompile the Dealer Demo , we need to start by peeking at the boot sectors to see how it starts.000010: SECTOR: 001: FILE:     0  ff 01 80 04 c0 e4 a9 f4-d0 06 00 0d 01 00 80 00   ................    10  85 f0 a9 52 8d 02 03 ad-8c 04 8d 0a 03 ad 8d 04   ...R.........…
The first...






December 2018

S M T W T F S
      1
2345678
9 10 1112131415
16171819202122
23242526272829
3031     

Tags

Categories