← Manual LibraryVCC Plus 3.7.1 · Reading on the web

Try the exercises in VCC Plus. Example links download files here; open them in the app to work beside the emulator.

The complete book · PDF editionBook 9: Assembly Language Programming for the VCC Plus CoCo 3

87 pages · VCC Plus 3.7.1 · Keep a copy to read or print.

Download PDF
Contents

Chapter 6 of 8

Move the packet with the HD6309

Try the same transfer with a different agreement between the program and the CPU. The portable loop uses B as a counter, A as a sum, and several instructions per byte. The Hitachi processor has a block-transfer instruction and a separate count register. You can see exactly which work it takes over.

Choose both processors deliberately

Save your guest work. In Machine Settings, choose the Hitachi HD6309 processor and apply the restart. Start at the Disk BASIC prompt. In Assembly Development, open a copy of dispatch6309.asm and set the assembler’s Target to HD6309. The Machine setting chooses what executes opcodes. Target chooses what the assembler accepts. As a negative check, choose the MC6809 target and Assemble: LDW and TFM are rejected. Return the target to HD6309 before continuing.

start       leax    packet,pcr
            leay    received,pcr
            ldw     #size       ; W counts the bytes left to transfer
copy        tfm     x+,y+       ; move from X to Y and increment both
inspect     leax    received,pcr ; stop here to inspect W, X, Y and RAM
next        lda     ,x+

W is a sixteen-bit register made from E (high byte) and F (low byte). D is similarly made from A and B. On the 6309, Q is the 32-bit combination D:W. The E register and the E flag in CC have different jobs. Watch W through E and F if the inspector shows the halves separately.

Cross the transfer in one debugger step

Set a stop on copy, choose Run, and look up packet and received in Symbols. At TFM, X points at the first input byte, Y at the first destination byte, and W is 3. Predict the pointer values after the copy. Step once, then inspect the four bytes at received in Mapped CPU.

Value At copy At inspect
PC in this build $3F0C $3F0F
X $3F28 $3F2B
Y $3F2B $3F2E
W $0003 $0000
Four destination bytes 00 00 00 00 4F 52 42 00

TFM X+,Y+ copies a byte, advances both pointers and counts down W. In VCC Plus the debugger presents this transfer as a whole instruction. The stop after it is where you compare the buffers. Continue prints ORB and returns. W supplied the count, and the fourth zero came from the original buffer declaration. This version never computes a checksum. Comparing its total run time with the first receiver would mix two different jobs.

Observe native mode, then give BASIC its mode back

The HD6309 can execute the preceding instructions in its startup compatibility mode. Native mode is a separate processor setting with effects including interrupt frames and instruction timing. To observe the distinction, use a freshly restarted HD6309 Disk BASIC guest. Save and open mode.asm. Set a stop on native and choose Run. The exercise assumes the reset value MD=$00. It saves CC and masks IRQ and FIRQ during its short mode-changing section. Keep it as supplied and let it finish.

start           pshs    cc              ; remember BASIC's interrupt masks
                orcc    #$50            ; mask IRQ and FIRQ for the short experiment
                ldmd    #1              ; select 6309 native mode
native          ldw     #$1234          ; inspect MD, then step and read E and F
                ldmd    #0              ; restore reset mode before calling BASIC
restored        puls    cc              ; restore the caller's condition codes
                rts

At native the instruction that selects mode 1 has executed. In the Debugger’s HD6309 registers inspect MD. Step LDW: E becomes $12 and F becomes $34. Step LDMD #0. At restored, MD reads $00 while the data in W still represents $1234. Continue restores the saved condition codes and returns to BASIC. Enter PRINT 2+3 to check that the guest is listening again.

Changing mode around an unknown interrupt handler would give that code a different environment. In particular, a full native-mode interrupt frame includes E and F. The interrupt experiment starts from a known mode and lets you inspect an actual frame. If you interrupt the mode experiment and lose your place, restart the disposable guest before continuing the book.

Original VCC Plus manuals © 2026 Brian K. Holman. Third-party references retain their authors’ copyrights and licenses. Artwork notices. Edition 3.7.1; source and export identity. Printable edition: PDF source and export identity.

A closer look

Open original