0% found this document useful (0 votes)
158 views6 pages

GOL 8 Documentation

The GOL-8 is an 8-bit processor that uses binary representations to encode instructions. There are different instruction formats depending on whether the instruction uses registers, constants, or addresses. Instructions include arithmetic, logic, stack, I/O, branching, and memory operations. The processor has 6 registers including the program counter (IP) and stack pointer (SP). Example programs are provided to demonstrate perfect squares calculation, a quine program, and a forward loop.

Uploaded by

niklas sheth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
158 views6 pages

GOL 8 Documentation

The GOL-8 is an 8-bit processor that uses binary representations to encode instructions. There are different instruction formats depending on whether the instruction uses registers, constants, or addresses. Instructions include arithmetic, logic, stack, I/O, branching, and memory operations. The processor has 6 registers including the program counter (IP) and stack pointer (SP). Example programs are provided to demonstrate perfect squares calculation, a quine program, and a forward loop.

Uploaded by

niklas sheth
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

GOL-8 Documentation

The GOL-8 Is an 8-bit MISC Processor.


How instructions are Represented in Binary:

Operation with Register And Constant: Two bytes

xxxxxvvv cccccccc
C = constant value
X = opcode
V = register

Operation with Two Registers: Two bytes

xxxxx111 vvv00vvv
X = opcode
V = register

Operation with One register (PSH, POP, OUT): One byte

xxxxxvvv
X = opcode
V = register

Operation with One constant (PSH, OUT): Two bytes

xxxxx000 cccccccc
X = opcode
C = constant

Unconditional Jump (JMP): Three bytes


xxxxx000 aaaaaaaa aaaaaaaa
X = opcode
A = 16 bit address

Conditional Jump / Memory Access (JEZ, LOD, STR): Three bytes


xxxxxvvv aaaaaaaa aaaaaaaa
X = opcode
A = 16 bit address
V = register
Instructions:
C = immediate value
R = register
A = Address

Math Operations: ​^(ADD|SUB|AND|BOR|XOR)\s\(%(AX|BX|CX|DX),\s(\$[0-9a-fA-F]{2}|%(AX|BX|CX|DX))\)


ADD (R, C/R) 00001 Example: ADD (%AX, $01) (cat a)
SUB (R, C/R) 00010 Example: SUB (%AX, %DX) (cat a)
AND (R, C/R) 00011 (cat a)
BOR (R, C/R) 00100 (cat a)
XOR (R, C/R) 00101 (cat a)
SHL (R) 00110 (cat b)
SHR (R) 00111 (cat b)
Misc operations (No operands):
NOP 00000
HLT 01101

Stack Operations:
PSH (C/R) 01000 (cat o)
POP (R) 01001 (cat b)

I/O Operations:
OUT (C/R) 01010 (cat o)

Branch Operations:
JMP (A) 01011 (cat j) Regex Verify: ^JMP\s\(@[0-9a-fA-F]{4}\)
JEZ (R, A) (Jump if R = 0) 01100 (cat i)

Memory Operations:
LOD (R, A) 01111 (cat i)
STR (R, A) 01110 (cat i)

Regex verify for cat a: ​^(ADD|SUB|AND|BOR|XOR)\s\(%(AX|BX|CX|DX),\s(\$[0-9a-fA-F]{2}|%(AX|BX|CX|DX))\)


Regex verify for cat b: ​^(SHL|SHR|POP)\s\(%(AX|BX|CX|DX)\)
Regex verify for cat o: ^(PSH|OUT)\s\((%(AX|BX|CX|DX)|\$[0-9a-fA-F]{2})\)
Regex verify for cat i: ^(LOD|STR|JEZ)\s\(%(AX|BX|CX|DX),\s@[0-9a-fA-F]{4}\)
Regex search for cat a, b, o: (%.{2})|(\$.{2})
Regex search for cat i, j: (@.{4})|(%.{2})
Registers:
All registers are prefixed with a “%”. There are 6 registers, but only 4 are accessible by
most operations.

Register Name Purpose

AX 8 Bit General Purpose Register

BX 8 Bit General Purpose Register

CX 8 Bit General Purpose Register

DX 8 Bit General Purpose Register

SP 16 Bit, Holds Address of Top of Stack.

IP 16 Bit, Holds Next Instruction to Execute.

Register Codes:

Register Binary Code

AX 001

BX 010

CX 011

DX 100
Example Programs:
Print perfect squares from 0 to 225:

OUT (%AX)
ADD (%CX, $1E)
;LOOP
SUB (%AX, %CX)
ADD (%AX, $1F)
OUT (%AX)
SUB (%CX, $02)
JEZ (%CX, @0010)
JMP (@0003)
HLT

Quine:

;Init
ADD (%CX, $23)
LOD (%AX, @0000)
;modify LOD
LOD (%BX, @0004)
ADD (%BX, $01)
STR (%BX, @0004)
PSH (%AX)
SUB (%CX, $01)
JEZ (%CX, @0016)
JMP (@0002)
;display code
ADD (%CX, $23)
POP (%DX)
OUT (%DX)
SUB (%CX, $01)
JEZ (%CX, @0022)
JMP (@0018)
HLT
Forward for loop:
ADD (%CX, $FF) ;$FF is the number of loop iterations
PSH (%CX)
XOR (%DX, %DX)
SUB (%DX, %CX)
;OUT (%DX)
;your code here! %DX is the loop counter
POP (%CX)
SUB (%CX, $01)
JEZ (%CX, @0011) ;change this
JMP (@0002)
HLT

You might also like