Chapter 1 of 8
Read the packet
A receiver reports ORB. Did it print those three letters from the message it received, or were they just the programmer’s favorite three letters? Catch the receiver after it has made a copy and before it decides what to print. At that instant you can ask the machine for evidence.
Set a stop on a decision
Start with a fresh Disk BASIC setup. Save any guest work before loading a program. Save dispatch.asm, choose Develop → Assembly Development…, then File → Open Source… and open your copy. Choose MC6809 as the assembler target. This program also runs on an HD6309. If stepping is new to you, try the one-byte experiment first.
Choose Assemble, open Build details → Listing, and look for three labels: packet, received and inspect. A label names the current assembly address. It can mark data just as easily as an instruction. Select the CMPA instruction on the inspect line, choose Set Stop, then Run. Confirm the load. Leave the machine paused for the next section.
Translate the listing into addresses
CHROUT equ $a002 ; indirect ROM character-output vector
org $3f00
start leax packet,pcr ; X walks the incoming bytes
leay received,pcr ; Y walks a separate writable buffer
ldb #size
bsr receive
inspect cmpa expected,pcr ; stop here to inspect A and the copy
bne damaged
The ORG places the first instruction at $3F00. The END at the bottom supplies the entry label. X will point at the input and Y at the destination. LDB #size loads the count itself. Read BSR receive as “call receive and save where to come back.” Execution is now back from that call. The instruction at the highlighted PC has yet to run.
The first instruction occupies four bytes, 30 8D 00 3C. LWASM used a signed 16-bit displacement in this build. The processor takes its position after the operand ($3F04) and adds $003C. That gives X the address $3F40. LEAX computes an address; it can do its job even before anyone looks at the character there. LEAY uses the same displacement but a different starting PC. Work it out from $3F08 before looking up received. Read your own listing after an edit: changing instruction length can move both labels.
Find the copy in RAM
In the workspace choose Debugger. Under Inspector → Memory, select Mapped CPU, enter 3F40 in Address, and choose Go. A row starts at the address printed on its left; the column adds the last hexadecimal digit. For this build, read across the row like this:
| Addresses | Contents at the stop | What placed them here |
|---|---|---|
| $3F40–$3F42 | 4F 52 42 | The assembler put the three character bytes of packet in the binary. |
| $3F43 | E3 | The author supplied the expected sum as data. |
| $3F44–$3F47 | 4F 52 42 00 | The receive routine wrote the first three bytes. The fourth was initialized to zero and left alone. |
| $3F48 onward | 43 48 45 43 4B 00 | The other message, CHECK, followed by a terminator. |
Open the registers. X=$3F43 and Y=$3F47 both point one past the last byte transferred. B has counted down to zero. In A, $E3 is a value calculated from the input. Compare it with the independent byte at $3F43. You have two pieces of evidence even though the guest has yet to print anything.
Return to the workspace and choose Continue. The guest prints ORB and returns to BASIC. Type PRINT 2+3, then Return. Seeing 5 tells you that BASIC is interpreting fresh input. Next you’ll change exactly one input byte and catch the same decision.