You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
142 lines
4.4 KiB
142 lines
4.4 KiB
RGPC1 technical information document
|
|
also known as the ramblings of a madman with too little coffee
|
|
|
|
Instruction layout in RAM
|
|
OPCODE A B
|
|
XXXXXXRR;AAAAAAAA;BBBBBBBB
|
|
AB
|
|
R Indicates the value stored in A/B is a register
|
|
|
|
Opcodes:
|
|
|
|
NUL = 00000000 Nothing but faster
|
|
NOP = 00101000 Nothing!
|
|
|
|
ALU = 1XXXXY--
|
|
If Y is 1 invert output
|
|
ADD = -1000Y-- Add A to B output to ACC
|
|
SUB = -0100Y-- Sub B from A output to ACC
|
|
OR = -1100Y-- OR A and B output to ACC
|
|
XOR = -0010Y-- XOR A and B output to ACC
|
|
AND = -1010Y-- AND A and B output to ACC
|
|
|
|
MOV = 010000-- Move A to B
|
|
|
|
JMP = 011000-- Jump to A ignore B
|
|
JNZ = 000100-- Jump if A is not zero to B
|
|
JGZ = 010100-- Jump if A is greater than zero to B
|
|
JLZ = 001100-- Jump if the eighth bit of A is set to 1 jump to B
|
|
JEZ = 011100-- Jump if A is zero to B
|
|
|
|
DBL = 000010-- Blink a light
|
|
DBB = 010010-- Beep a beeper
|
|
|
|
HLT = 000001-- Haha die
|
|
|
|
Registers:
|
|
|
|
RAM = 1XXXXXCC R/W 8bit wide 96 bytes total 32 instructions
|
|
-00000-- | -11111--
|
|
C 00 = OPCODE
|
|
C 10 = B
|
|
C 01 = A
|
|
|
|
ACC = 01000000 R 8bit
|
|
A = 00100000 R/W 8bit
|
|
B = 01100000 R/W 8bit
|
|
C = 00010000 R/W 8bit
|
|
|
|
Special:
|
|
ZERO = 00000000 R 8bit
|
|
FULL = 00000001 R 8bit
|
|
DBGO = 00000010 W Debug output 8bit
|
|
DBGI = 00000011 R Debug input 8bit
|
|
PGCR = 00000100 R/W Program Counter 5bit
|
|
GPIO = 00000101 R/W 8bit
|
|
|
|
Example program (Human readable + binary):
|
|
OPCODE A B
|
|
MOV 1 A 0100001;00000001;00100000
|
|
MOV 1 B 0100001;00000001;01100000
|
|
NUL 0000000;00000000;00000000
|
|
MOV A DBGO 0100011;00100000;00000010
|
|
ADD A B 1100011;00100000;01100000
|
|
MOV A B 0100011;00100000;01100000
|
|
MOV ACC A 0100011;01000000;00100000
|
|
JMP 2 0110000;00000010;00000000
|
|
|
|
Programming information:
|
|
R|I = Register or number
|
|
|
|
ALU Operation usage:
|
|
Not is optional and inverts the output
|
|
|
|
ADD R|I R|I NOT
|
|
SUB R|I R|I NOT
|
|
OR R|I R|I NOT
|
|
XOR R|I R|I NOT
|
|
AND R|I R|I NOT
|
|
|
|
Jumps:
|
|
Markers are defined by doing:
|
|
!marker_name
|
|
|
|
JMP marker_name
|
|
Anything else is ignored by the compiler
|
|
|
|
JNZ R|I marker_name
|
|
JGZ R|I marker_name
|
|
JLZ R|I marker_name
|
|
JEZ R|I marker_name
|
|
|
|
MOV:
|
|
MOV will move A into B
|
|
A B
|
|
MOV R|I R|I
|
|
|
|
DBL will blink a light in the control logic
|
|
DBB will beep a beeper in the control logic
|
|
|
|
NUL will do nothing and be somewhat quick about it
|
|
NOP will do nothing but be slow about it
|
|
|
|
HLT will stop the machine
|
|
|
|
Certain instructions like:
|
|
(Parts of the instruction that can store arbitrary data)
|
|
* JMP (8b: B)
|
|
* NUL (16b: A B)
|
|
* NOP (16b: A B)
|
|
* HLT (16b: A B)
|
|
* DBL (16b: A B)
|
|
* DBB (16b: A B)
|
|
|
|
Can be used to store data some data in RAM since they dont use all 24 bits
|
|
|
|
For people working with GPIO:
|
|
When you try to read GPIO it sends the read pulse
|
|
you do not need to make it read and this can be used as a general pulse
|
|
same thing happens with read
|
|
|
|
Control bus:
|
|
Layer one:
|
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
|
C R R R R R R R R R P P A A B B C C Z F D D D D
|
|
L A A A A A A A A A G G R W R W R W E U B B B B
|
|
O M M M M M M M M M C C R L G G G G
|
|
C L L L L L C C R W R W O L O I H S
|
|
K R R W R L T
|
|
T A
|
|
R
|
|
T
|
|
|
|
Layer two:
|
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
|
A A A A A A A A A G G X X X X X X X X X X X X X
|
|
L L L L L L L L C P P
|
|
U U U U U U U U C I I
|
|
- - - - - - - - R O O
|
|
A B N A S O X A R W
|
|
W W O D U R O N
|
|
T D B R D
|