The Assembler

Write machine code freely · every 6809 command

An assembler is a translator: you write commands in words, like LDA #$41, and it turns them into the numbers the processor understands. The course met some of the commands. Here you can use all of them.

Write in the box, and right below you see every line with its address and its numbers. ▶ Run runs the program on the Dragon screen in the page, and Step runs one command and shows what changed in the drawers and lamps. When the program is ready, 🐉 Send to the machine takes it to the site's Dragon machine, like a tape.

The program is kept in this browser only, and stays after you close the page.

🐉 Want to work as in 1983, inside the Dragon itself? The Dragon Assembler is a tape on the shelf: the same syntax and the same bytes, with numbered lines as in BASIC.

Help: how to write

A line

A place name (like LOOP) is written at the very start of the line. A command comes after a space, so a line with no name starts with a space. Whatever comes after the command and another space is a comment. A line that starts with * is all comment.

LOOP STA ,X+     * write and move X
 INCA

Numbers

$41 hex, %01000001 binary, 65 ordinary, 'A the letter's code. Sums work too: LOOP+2, SCREEN+32*3, (SIZE+1)*2, WIDTH/2, *-1 (* on its own is this line's address). Times and divide come first, then plus and minus; division is in whole numbers.

Instructions for the translator

ORG $3000Where in memory to put the program. With no ORG it starts at $2EE1, as in the course.
SCREEN EQU $0400Give a number a name.
FCB 1,2,3Put bytes in memory (each 0 to 255).
FDB $0400,LOOPPut two-byte numbers.
FCC /HELLO/Put the codes of a text.
RMB 10Keep 10 empty bytes.
@A special name: the program starts running here (as in the course). With no @ it starts at the first byte.

Going back to BASIC: RTS

On the machine, EXEC jumps to the program like JSR, and puts on the stack the place to come back to. At the end of the program write RTS, and the computer goes back to BASIC and its OK. Whatever you put on the stack (PSHS) take off before the RTS. To see the screen before the OK appears, wait for a key first:

KEY LDX $A000    * the keyboard check's address
 JSR ,X          * A = the key, or 0
 BEQ KEY         * no key? again
 RTS             * back to BASIC

What the page shows, and what only the machine shows

The page shows the text screen ($0400 to $05FF), the memory, the drawers, the lamps and the keyboard check. Sound ($FF20), graphics (PMODE, $FFC0) and other calls into the BASIC ROM you see only on the machine: the page stops and says "You see this on the machine", and you send it there with the 🐉 button. The page also stops a loop that never ends, and writing outside the program's memory and the screen.

Where to learn

This is a tool we wrote ourselves, inspired by how DREAM worked in 1983. DREAM itself isn't ours, and it isn't on the site.

One difference from DREAM: square brackets, as in JSR [$A000], work here as they do on the real processor. DREAM ignores them.

A hobbyist tribute project, not affiliated with or endorsed by Dragon Data. The course, drawings and text are our own. Every program in the course was checked on the site's Dragon machine (XRoar running the BASIC we wrote).