index

(note: all the writing on this page is new in 2016. Only the photographed assembler code is from 1984.)

Assembler Code for Magellan

This is part of Magellan, the linked list Dictionary of basic built-in modules. Each module has this common structure, using "-?" as an example:

09 size of module, including self
03 size of module's name, plus self
2D 3F name "-?" in ascii
B5 01machine code entry point
10 B6
60final machine code is usually RET aka RS (return from subroutine), or a JMP or branch to some other module's code, taking advantage of its final RS opcode.

Peculiar Assembly Language

I used my own made-up version of assembler for the 6502. "LAI" was Load A Immediate. "LA0", ending with a zero not letter "Oh" is Load A from page zero - taking one address byte. LDA was the full 16-bit address Load A, but t this is rarely used. "SA0" was Store A in page zero.

Register A could read or write indirectly using either the Y register, used as an unsigned 8-bit offset relative to a given 16-bit address, or using the X register as an index into page zero memory, whereat would be the 16-bit address of the byte to read/write. Beside just reading data, fetched data could be added (AD*), subtracted (SU*), bitwise AND, OR, or XORed (AN*, OR*, EO*) where '*' is I for Immediate, 0 (zero not Oh) for page-zero, or X or Y for the indirect modes. Non-memory operations included shifts, SHR and SHL, for one bit position only, there being nothing like the counter capability or barrel shifter in better CPUs such as the 8086.

The X and Y registers could read/write to memory, but never indirectly.

There were increment and decrement instructions, the usual branches, and other that are either obvious the the seasoned assembler programmer albeit odd looking, or not obvious in which case - I don't know either! This was about thirty years ago (at this writing, 2016).

Super-Tight!

Note the super-tight space optimization seen for example on page 4, where the "-" does most of its work then jumps to code near the end of the "+" routine. The code could have been in-place, taking four bytes, but the jump is only three bytes. It costs a couple clock cycles, but space was so tight, I decided it was more important to save one byte each in "-", "&", "OR" and "XOR" (p. 5).

The comparison operator >? is defined as swapping the top two elements, then jumping to the routine for

Photographed pages from 1984

Page Image Modules Shown
1 nameless zeroth module, S Sb F Fb
2 ^ V 0 1 -1 IN
3 IL 0? -? ? D? L?
4 | 1+ 1- + - & OR
5 XOR COM NEG OUT CR LF SP GO
6 1&2 2&3 1&3 V2 ^2, and two nameless modules to push backgrabbed constants
7 nameless modules for handling conditional execution
8 [ ] .
9 MBN B@ →M
10 * /& (multiply, divide-remainer operations)
11 ☐    ☐→    ☐→    →*    *→*

Daren Scot Wilson's personal site
linkedin