Gyo is a register machine with 16 instructions.

Gyo was designed as an educational system foundational computing concepts. The computer has 16 registers, 16 opcodes and 256 memory addresses. The gyo assembler syntax supports =constants and :labels. The computer and assembler are written in less than 400 lines of ANSI C code.


Each instruction uses 4-bits for the operation, 4-bits for the addressing mode and 8 bits for the address. The instructions are written directly into the RAM and read from the memory, the program can be modified as it is running. Programs are loaded directly into memory to create procedural self-modifiable programs.

0x1JMPJump to position in memory
0x2JCAJump to position in memory, when carryflag
0x3JZEJump to position in memory, when not zeroflag
0x4PEKRead status
0x5POKWrite status
0x6GETStore in register
0x7PUTStore in memory
0x8ADDAdd value to register, set carryflag when overflow
0x9SUBSubstract value from register, set carryflag when overflow
0xAEQUCompare register with value, set zeroflag when equal
0xBLESCompare register with value, set zeroflag when less than
0xCANDBitwise AND operator
0xDXORBitwise XOR operator
0xEROLBitwise rotate left
0xFRORBitwise rotate right

There are 4 principal addressing modes:

EQU #00the raw value
EQU $EFthe value at address #EF in memory
EQU [e]the value of the 15th register
EQU {e}the value at the address of the 15th register

Registers are used by reading and writing to the status using a combination of bitwise operators, to quickly select the 3rd register and set all flags to 0, use POK #20.


The assembler syntax supports :label, ~const and =var.

; comment

=rate #01 ; defines a constant

; program 

	GET $02
	PUT #03


The following example demonstrate how to do a conditional jump.

	GET #EF         ; load #EF in register
	EQU [1]         ; set zeroflag if r0 is equal to r1
	JZE there       ; if equal, goto :there
	PUT #10         ; write in memory at #10
	PUT #20         ; write in memory at #20


The following example demonstrate how to do a basic loop.

	ADD #01
	EQU #0f
	JZE end
	JMP loop

Status Register

The status register is distributed as follows, it shares the same byte as the register selector. The halt flag is used by the BRK instruction is stops the cpu, the zero flag is used for logic instructions, the carry flag is set when an instruction carries over the 8bit range and the traps flag is set when the pointer should be sent to the traps location(in IO operations).

| | | +---- Halt
| | +------ Zero
| +-------- Carry
+---------- Traps


To begin IO mode, activate the traps flag with POK #08.

	POK #08  ; Set traps flag ON
	GET      ; Read character from stdin
	PUT [0]  ; Write character to stdout
	POK #00  ; Set traps flag OFF 

Hello World

	POK #20   ; select r2
	GET hello ; store location of :hello
	POK #00   ; select r0
	GET [1]   ; get value of r1
	ADD [2]   ; add value of r2
	POK #08   ; set traps flag
	PUT {0}   ; stdout value of memory[r0]
	POK #10   ; select r1, remove traps
	ADD #01   ; add 1
	EQU #06   ; set zeroflag if == 6
	JZE end   ; end if true
	JMP loop  ; repeat

	#48 #65
	#6C #6C
	#6F #0A