Myth Microcontroller Documentation

Assembler Notation and Conventions

Bit positions are numbered starting from 0 (LSB - least significant bit) to 7 (MSB), usually with the letter 'b' for 'bit' prefixed. Single uppercase letters refer to registers when used in the text. Instruction mnemonics use lowercase.

Page, Offset, Pointer

The word 'Page' refers to the high-order address byte, and 'Offset' is the low-order address byte. A full 16-bit address is referred to as a 'Pointer' in this project. This word is mainly used for register pairs such as G_O or C_PC etc., which are functionally related.

Comments

Place comments into parentheses (nesting is not implemented). A semicolon (";") works as a line comment.

Phrasing

Multiple assembler mnemonics can occur on a single line. Commas (",") can optionally be used for grouping "phrases" of instructions that logically belong together. They don't generate code and are just for visual clarity.

Number Literals

Decimal numbers from 0-255 can be included in the source text as literals, and be prefixed by an optional minus sign. Hexadecimal numbers must be in two uppercase digits and marked with the suffix "h", for instance: "80h" for 128. Binary numbers can either be formatted as four numeric digits with the suffic "b" (1111b = 15), or in the following way, as two 4-bit groups separated by an underscore ("_") with the suffix "b", for instance: "0010_0000b" for 32.

Strings and Characters

Characters enclosed in double quotation marks such as "Hello World" are assembled to strings of characters.

Page Labels

P[label] defines a label with the page index of the object code pointer as its value. P[label]index does the same, but also sets the page index of the pointer to 'index'. P[label]+ defines label as before, advances the page index of the pointer by 1 and sets the offset position to zero. Page indices can be targets of CALL and TRAP instructions. They can be used as literals anywhere in the code.

Offset Labels

O[label] defines a label with the offset of the object code pointer as its value. O[label]offset does the same, but also sets the offset of the pointer to 'offset'. Offset labels can be jumped to, or they can represent address offsets within a page.

Trap Labels

An asterisk placed before a page label encodes a trap call instruction to that address. Such label references will generate an opcode that will trigger a TRAP and call the handler function referenced by the label.

Constants

C[label]value defines a constant.

Label References

Page and offset labels are referenced by prefixing their identifier with "<" (for backward references, i.e. the label is defined earlier in the source code than the reference to it), or with ">" (forward reference, i.e. the label is defined later than the reference to it in the source code). If a label is not unique, the reference goes to the nearest occurrence of it in the given direction. A label reference is just a numerical value and can be used as a literal anywhere in the code.

An offset label can be referenced without the directional prefix, by fully qualifying it with the pagelabel of the page where it is defined, for example: PAGELABEL.offslabel.

Local page and L-variables

The local page is the one whose page index is stored in the L register. Subroutine calls and traps decrement L, the RET instruction increments L. This essentially pushes and pops 256-byte call-stack frames.

The high-order 8 bytes of the local page are named, and work in a special way. They are referred to as L0 (local page offset F8h) to L7 (offset FFh). The RET instruction expects the page index of the caller-code to be in L7. There is a group of instructions that copy values between registers G, I, R, O and the local variables L0-L7.

Local variable shortcuts (GIRO get/put)

Examples: r0 ("PUT R into local var L0"), 4o ("GET O from local var L4").