117 lines
4.5 KiB
Markdown
117 lines
4.5 KiB
Markdown
Thingamajig
|
||
===========
|
||
|
||
Thingamajig is a RISC-y and MISC-y homebrew computer architecture. Its
|
||
git repository can be found at
|
||
https://ahti.space/git/crazyettin/Thingamajig.
|
||
|
||
Included Software
|
||
-----------------
|
||
|
||
The repository includes an emulator implementation of Thingamajig with a
|
||
control program for the emulated punched tape reader and punch, and an
|
||
assembler and a disassembler, all written in FreePascal. It also
|
||
includes couple of simple example programs for Thingamajig written in
|
||
Assembly.
|
||
|
||
Registers and Memory
|
||
--------------------
|
||
|
||
* 24-bit instruction register IR
|
||
* 16-bit instruction and return pointers IP and RP
|
||
* 8-bit general-purpose registers R0-R3
|
||
* 8-bit memory locations 0-FFFF
|
||
|
||
Multi-byte values are big-endian. Memory locations 0-FFEF are used for
|
||
RAM while FFF0-FFFF are reserved for memory mapped devices. Input and
|
||
output are mapped to address FFFF, while arbitrary devices can be mapped
|
||
to the other reserved addresses.
|
||
|
||
Instructions
|
||
------------
|
||
|
||
Instructions without an immediate or address argument are 8-bit, those
|
||
with an immediate one 16-bit, and those with an address one 24-bit. The
|
||
instruction pointer is incremented before being accessed or modified.
|
||
|
||
0 HALT
|
||
1 RET IP = *RP; RP += 2
|
||
|
||
2 SHL RX RX <<= 1 Logical shifts
|
||
3 SHR RX RX >>= 1
|
||
4 ROL RX RX <<= 1 Rotating shifts
|
||
5 ROR RX RX >>= 1
|
||
|
||
6 NAND RX, RY RX = ~(RX & RY)
|
||
7 AND RX, RY RX &= RY
|
||
8 OR RX, RY RX |= RY
|
||
9 XOR RX, RY RX ^= RY
|
||
|
||
A LOAD RX, ~0, IMM RX = IMM Written as "LOAD RX, #IMM"
|
||
0, ADDR RX = *ADDR Written as "LOAD RX, ADDR"
|
||
B STORE RY, ADDR *ADDR = RY Written as "STORE ADDR, RY"
|
||
|
||
C BREQ RX, RY, ADDR if (RX == RY) IP = ADDR
|
||
D BRNEQ RX, RY, ADDR if (RX != RY) IP = ADDR
|
||
E CLEQ RX, RY, ADDR if (RX == RY) {RP -= 2; *RP = IP; IP = ADDR}
|
||
F CLNEQ RX, RY, ADDR if (RX != RY) {RP -= 2; *RP = IP; IP = ADDR}
|
||
|
||
Assembly Language
|
||
-----------------
|
||
|
||
Lines of assembly are of the following form:
|
||
|
||
LABEL: OPER ARG1, ARG2, ARG3 ;Comment
|
||
|
||
The language is case-insensitive and uses hexadecimal numbers. A label
|
||
can consist of any alphanumeric characters as long as it is not
|
||
interpretable as a hexadecimal number. The label, instruction, and
|
||
comment elements are all optional, as is spacing between the arguments.
|
||
For the arguments of each instruction see the previous section.
|
||
|
||
Address arguments can be either absolute addresses or references to or
|
||
relative to a label. Relative references are of the form LABEL +/- N,
|
||
the spacing being optional.
|
||
|
||
In addition to the true instructions there are three
|
||
pseudo-instructions. ORG defines the starting address of the program: it
|
||
can only occur as the first instruction and cannot have a label, and is
|
||
not required if the starting address is 0. DATA introduces a byte of
|
||
data. ADDR introduces two bytes of data containing the address of a
|
||
reference to or relative to a label.
|
||
|
||
Boot
|
||
----
|
||
|
||
At boot the initial program loader (IPL) loads a program to RAM starting
|
||
at address 0 after which is cedes control to the CPU. If an
|
||
implementation has a front panel the IPL is optional. The instruction
|
||
and return pointers are initialised as 0 and the first address after RAM
|
||
respectively, while other registers and RAM are uninitialised.
|
||
|
||
Emulator
|
||
--------
|
||
|
||
By default the emulator runs at roughly 500 KIPS, has 2 KiB of RAM, and
|
||
interacts with memory mapped devices at roughly 1000 CPS. The arguments
|
||
-dRAM4, -dRAM8, -dRAM16, -dRAM32, and -dRAM64 can be used to compile
|
||
the emulator with 4, 8, 16, 32, or 64 KiB (minus the reserved addresses)
|
||
of RAM respectively instead and the speed limitations can be removed
|
||
with the argument -dfast.
|
||
|
||
Input and output are handled by an emulated glass teletype terminal with
|
||
local echo. Of the control characters only bell, backspace, line feed,
|
||
and carriage return are used by the terminal. The backspace and delete
|
||
characters are tied to their respective keys, and non-character keys
|
||
input null.
|
||
|
||
In Linux the emulator can be compiled with support for a character
|
||
printer and an emulated punched tape reader and punch with the arguments
|
||
-dprinter and -dtape respectively. The printer is mapped to address FFFE
|
||
and the tape reader and punch to FFFD. The printer prints into
|
||
/dev/usb/lp0 and the tape files read from and punched to are (re)set
|
||
using the program tapectl.
|
||
|
||
The IPL loads a program from a file specified when launching the
|
||
emulator.
|
||
|