2022-07-23 20:05:32 +00:00
|
|
|
Thingamajig
|
|
|
|
===========
|
|
|
|
|
2022-07-27 14:11:09 +00:00
|
|
|
Thingamajig is a RISC-y and MISC-y homebrew computer architecture. Its
|
2022-07-24 19:47:37 +00:00
|
|
|
git repository can be found at
|
2022-07-23 20:05:32 +00:00
|
|
|
https://ahti.space/git/crazyettin/Thingamajig.
|
|
|
|
|
|
|
|
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 addresses 0-FFFF
|
|
|
|
|
|
|
|
Multi-byte values are big-endian. Memory addresses FFF0-FFFF are
|
2022-07-27 14:11:09 +00:00
|
|
|
reserved for memory mapped devices; the instruction and return pointers
|
|
|
|
cannot have values higher than FFEF and FFF0 respectively to avoid them.
|
|
|
|
The instruction and return pointers are initialised as 0 and FFF0
|
|
|
|
respectively, while other registers and memory are unitialised.
|
2022-07-23 20:05:32 +00:00
|
|
|
|
|
|
|
Instructions
|
|
|
|
------------
|
|
|
|
|
|
|
|
Instructions without an address argument are 8-bit and those with one
|
|
|
|
24-bit. The instruction pointer is incremented before being accessed or
|
|
|
|
modified.
|
|
|
|
|
|
|
|
0 HALT
|
2022-07-27 14:11:09 +00:00
|
|
|
1 RET IP = *RP; RP += 2
|
2022-07-23 20:05:32 +00:00
|
|
|
|
|
|
|
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, ADDR RX = *ADDR
|
|
|
|
B STORE RX, ADDR *ADDR = RX Written as "STORE ADDR, RX" in
|
|
|
|
assembly for the sake of
|
|
|
|
consistency.
|
|
|
|
|
|
|
|
C BREQ RX, RY, ADDR if (RX == RY) IP = ADDR
|
|
|
|
D BRNEQ RX, RY, ADDR if (RX != RY) IP = ADDR
|
2022-07-27 14:11:09 +00:00
|
|
|
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}
|
2022-07-24 19:47:37 +00:00
|
|
|
|
2022-07-31 11:09:15 +00:00
|
|
|
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.
|
|
|
|
|
2022-08-02 06:21:47 +00:00
|
|
|
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.
|
|
|
|
|
2022-07-31 11:09:15 +00:00
|
|
|
In addition to the true instructions there are two 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.
|
|
|
|
|
2022-08-02 06:21:47 +00:00
|
|
|
Note that the assembler does not check for addresses or references to
|
|
|
|
reserved addresses or references to or relative to non-existing labels.
|
2022-07-31 18:58:23 +00:00
|
|
|
|
2022-07-24 19:47:37 +00:00
|
|
|
Memory-Mapped Devices
|
|
|
|
---------------------
|
|
|
|
|
|
|
|
Input (when read from) and output (when written to) are mapped to
|
2022-07-27 14:11:09 +00:00
|
|
|
address FFFF. The emulator emulates a dumb terminal for this.
|
2022-07-24 19:47:37 +00:00
|
|
|
|
|
|
|
Arbitrary devices can be mapped to the other reserved addresses.
|
|
|
|
|
|
|
|
Initial Program Loader
|
|
|
|
----------------------
|
|
|
|
|
|
|
|
At boot the initial program loader loads a program to the memory
|
2022-07-27 14:11:09 +00:00
|
|
|
starting from address 0 after which is cedes control to the CPU. The
|
|
|
|
emulator loads the program from a file.
|