Line 5... |
Line 5... |
3. fixed 16-bit instruction length
|
3. fixed 16-bit instruction length
|
4. use a small amount of "rich" instructions to do powerful things
|
4. use a small amount of "rich" instructions to do powerful things
|
5. 1 instruction per clock cycle
|
5. 1 instruction per clock cycle
|
|
|
Register list:
|
Register list:
|
r0-r2 general purpose registers
|
r0-r6 general purpose registers
|
ip instruction pointer register (represented as r3)
|
ip instruction pointer register (represented as r7)
|
cs, ds, es, ss segment registers (code segment, data segment, extra segment, stack segment)
|
cs, ds, es, ss segment registers (code segment, data segment, extra segment, stack segment)
|
tr truth register for conditionals
|
tr truth register for conditionals
|
|
|
general opcode format
|
general opcode format
|
|
|
first byte:
|
first byte:
|
first 4 bits: actual instruction
|
first 4 bits: actual instruction
|
next 2 bits: (target) register
|
next 3 bits: (target) register
|
last 2 bits: conditional
|
last 1 bit: conditional
|
|
|
second byte:
|
second byte:
|
first 1 bit: use segment registers
|
first 1 bit: second portion of condition (if not immediate) (1 for only if false)
|
next 1 bit: exchange target and source register
|
next 1 bit: unused
|
next 2 bits: other register
|
next 3 bits: other register
|
next 1 bit: dereference first register for memory (respecting the "exchange" bit)
|
last 3 bits: extra opcode information or third register. such as for ADD it could be target=source+third_register
|
next 3 bits: extra opcode information(optional) or last two bits is third register (such as for ADD it could be target=source+third_register)
|
|
|
|
...or second byte is immediate value
|
...or second byte is immediate value
|
|
|
For opcodes requiring 3 registers but without room, the target opcode is assume to be the second operation. Such as for AND, target=source AND target
|
For opcodes requiring 3 registers but without room, the target opcode is assume to be the second operation. Such as for AND, target=source AND target
|
|
|
short list of instructions: (not final, still planning)
|
short list of instructions: (not final, still planning)
|
|
immediates:
|
|
1. move reg, immediate
|
|
2. move [reg], immediate
|
|
3. push and move reg, immediate (or call immediate)
|
|
4. push immediate
|
|
|
|
groups: (limited to 2 registers and no immediates. each group has 8 opcodes)
|
|
group 1:
|
|
move(store) [reg],reg
|
|
move(load) reg,[reg]
|
|
out reg1,reg2 (output to port reg1 value reg2)
|
|
in reg1,reg2 (input from port reg2 and store in reg1)
|
|
|
|
|
|
group 2:
|
|
and reg1,reg2 (reg1=reg1 and reg2)
|
|
or reg, reg
|
|
xor reg,reg
|
|
not reg1,reg2 (reg1=not reg2)
|
|
left shift reg,reg
|
|
right shift reg,reg
|
|
rotate right reg,reg
|
|
rotate left reg,reg
|
|
|
|
group 3: compares
|
|
is greater than reg1,reg2 (TR=reg1>reg2)
|
|
is greater or equal to reg,reg
|
|
is less than reg,reg
|
|
is less than or equal to reg,reg
|
|
is equal to reg,reg
|
|
is not equal to reg,reg
|
|
|
|
|
|
|
|
|
|
3 register instructions:
|
|
1. add reg1, reg2, reg3 (reg1=reg2+reg3)
|
|
2. sub reg1, reg2, reg3
|
|
|
|
|
|
|
|
|
0 -nop (doesn't do a thing)
|
0 -nop (doesn't do a thing)
|
1 -move immediate (only uses first byte)
|
1 -move immediate (only uses first byte)
|
2 -move
|
2 -move
|
3 -push
|
3 -push
|
4 -push immediate
|
4 -push immediate
|
Line 45... |
Line 86... |
x -multiply (if room)
|
x -multiply (if room)
|
x -divide
|
x -divide
|
|
|
|
|
conditionals
|
conditionals
|
00 -- always
|
0 -- always
|
01 -- if true
|
1 -- only if true
|
10 -- if false
|
for only if false, there should basically be another compare or if applicable an always afterwards
|
11 -- reserved/not used
|
|
|
|
push
|
push
|
pop
|
pop
|
move
|
move
|
add
|
add
|