12-30-2013, 01:49 PM
Update: Mort and I extended the Morcor IS to include some necessary features. Here is the new version:
It is far from complete but it is a fairly good starting point.
Quote:1 bit - Immediate Flag for ARG1 - IMM1
1 bit - Immediate Flag for ARG2 - IMM2
5 bit - OP Code - OP
4 bit - Result Register - RS
8 bit - Argument #1 - ARG1
8 bit - Argument #2 - ARG2
ARG1: If IMM1: Immediate value. Else: Register (Address).
ARG2: If IMM2: Immediate value. Else: Register (Address).
# Instruction word:
IMM1 - IMM2 - OP - RS - ARG1 - ARGS
1 1 5 8 8 8 = 31 bits
00000 - NOP - No instruction
# Memory
00001 - MOV - RS = ARG1
00010 - DIN - RS = Lowest 8 bits = ARG1, highest 8 bits = ARG2
# Arithmetic
00011 - ADD - RS = ARG1 + ARG2
00100 - SUB - RS = ARG1 - ARG2
00101 - RSHIFT - RS = ARG1 RSHIFT
# Logic
00110 - OR - RS = ARG1 OR ARG2
00111 - AND - RS = ARG1 AND ARG2
01000 - XOR - RS = ARG1 XOR ARG2
# Inverted logic
01001 - NOR - RS = ARG1 NOR ARG2
01010 - NAND - RS = ARG1 NAND ARG2
01011 - XNOR - RS = ARG1 XNOR ARG2
# Branch logic
01100 - CMP - Compare ARG1 and ARG2 and update the FLAGS register.
01101 - JEQ - Branch to RS if ARG1 == ARG2
01110 - JGT - Branch to RS if ARG1 > ARG2
01111 - JLT - Branch to RS if ARG1 < ARG2
# Input/Output
10000 - WRITE - Output ARG1 to device ID ARG2
10001 - READ - RS = Input from device with ID=ARG2. Halts CPU until input from desired ID.
# Stack
10010 - PUSH - push ARG1 to stack
10011 - POP - RS = pop from stack
# Pointers
10100 - LDP - RS = *ARG1 (The value at the memory location specified by the contents of ARG1)
10101 - SVP - *ARG1 = ARG2
# CPU State
10110 - STOP - Stops the execution and resets program counter.
10111 - HALT - Halts the CPU until the user resumes the execution.
It is far from complete but it is a fairly good starting point.