Close

Architectual Limitations

A project log for Assembler for SuperconBadge

An Assembler for the Supercon 6 Badge - been done. But *ON* the badge?

michael-mllerMichael Möller 05/31/2023 at 19:390 Comments

These are the design thoughts at the beginning,. Is this at all possible?

The computer is Harvard Architecture. That means the assembler can not generate the machinecode to program memory directly. The solution is the output is sent via the Serial to an external device where it is stored, so it can be loaded with hardware loader from Serial.

The computer is also severly RAM limited - 191 nibbles are available (a bit more if we avoid some instructions). Thus the source text has to be stored externally, read in via the Serial, parsed and generate the machine code, character by character, as there is no room to buffer anything.

Labels for jumps need a symbol table. 12bit program location means 3 nibbles. If a label is two characters long 9 nibbles are needed per label meaning we have room for about 20 labels using all RAM. Syntax of labels is therefore limited to one the 26 letters of the alphabet. Thus we do not store the labelname/character, but use a fixed size table and labelnames are inferred by position.

Secondly, backward references can be fully resolved in the 1st pass. These can be redefined at the programmers responsibility. Single characters here, too, and for clarity the "0"-"9" are used. This is necessary as 26 labels in total is too few; this way the global symbols are only used for "major" labels, and when a forward jump is unavoidable.

Thus the symbol table only needs 106 nibbles, leaving us room for other stuff. I am undecided on symbolic names for data locations. Restricting them to one character [A-J], only using 2 nibbles for an 8 bit address uses 20 nibbles, leaving 65 nibblesfor buffers or something - or longer symbol tables.

Any decent assembler needs to handle forward references, typically done as a two pass assembler. (The other way is backward patching, but the binary loader does not support that) The first pass collects the global symbols in memory and generates "object"-code (to the Serial), with placeholder for unresolved symbols;. The second pass reads this and generates the final machine code joining it with in-memory symbol table and thus generates the final binary format suitable for the loader. One might call the 2nd pass a Linker.

Coding mantra: Waste program memory (bulky code) to save on RAM. Use backwards jumps so we use fewer global symbols, and save on stack (it is only 5 deep). It ain't gonna be pretty, sorry.

Discussions