For our final project, we decided we to implement a CISC on RISC computer
system in C. This is a virtual machine, because it is written entirely in C. We
wanted to restrict the number of RISC instructions, while still allowing a large
number of CISC instructions to be implemented. We give our program a file
containing a list of CISC instructions for an algorithm. Our C program
(interpreter) then decodes these CISC instructions into RISC instructions which
actually carry out the program.
Even though CISC gives you more options and more flexibility, RISC makes the
CPU faster, and that is all that matters. The Pentium IV is CISC on RISC, the
PowerPC is RISC. Nearly all modern systems function as a RISC computer at the hardware level,
because it is so much faster.
Using CISC on RISC combines the versatility of CISC with the speed of
RISC. In a CISC on RISC computer, programs are interpreted as lists of
CISC instructions. These CISC instructions are then translated into RISC
instructions which are computed in hardware. A CPU can interpret CISC instructions that come much farther in the program than the one currently being executed and thus create a large RISC instruction buffer to be used for pipelining and superscalar processing. Our particular project is a virtual
machine, since we are only using an upper level programming language, instead of
hardware and machine code.
CISC Instruction | Argument 1 | Argument 2 | Description |
---|---|---|---|
LOADM | memory location | immediate value | Load the arg2 immediate value into the arg1 memory location |
LOADR | register location | immediate value | Load the arg2 immediate value into the arg1 register |
CISC Instruction | Argument 1 | Argument 2 | Description |
---|---|---|---|
ADDRM | register location | memory location | Add value in arg1 register to the value in arg2 memory location, store in arg1 register |
ADDRR | register location | register location | Add the value in the arg1 register to the value in the arg2 register, store in arg1 register |
ADDRI | register location | immediate value | Add value in the arg1 register to the immediate value of arg2, store in arg1 register |
ADDRN | register location | indirect register | Add value in the arg1 register to the value stored in the value of arg2's register, store in arg1 register |
ADDMM | memory location | memory location | Add the value in arg1 memory location to the value in arg2 memory location, store in arg1 memory location |
ADDMR | memory location | register location | Add the value in arg1 memory location to the value in arg2 register, store in arg1 memory location |
ADDMI | memory location | immediate value | Add the value in arg1 memory location to the immediate value of arg2, store in arg1 memory location |
ADDMN | memory location | indirect register | Add the value in arg1 memory location to the value stored in the value of arg2's register, store in the arg1 memory location |
ADDNM | indirect register | memory location | Add the value in the value of arg1's register to the memory location, store in the arg1 indirect register |
ADDNI | indirect register | immediate value | Add the value in the value of arg1's register to the immediate value of arg2, store in the arg1 indirect register |
ADDNN | indirect register | indirect register | Add the value in the value of arg1's register to the value in the value of arg2's register, store in the arg1 indirect register |
CISC Instruction | Argument 1 | Argument 2 | Description |
---|---|---|---|
SUBRM | register location | memory location | Subtract the value in arg2 memory location from the value in arg1 register, store in arg1 register |
SUBRR | register location | register location | Subtract the value in the arg2 register from the value in the arg1 register, store in arg1 register |
SUBRI | register location | immediate value | Subtract the value in the immediate value of arg2 from the arg1 register, store in arg1 register |
SUBRN | register location | indirect register | Subtract the value stored in the value of arg2's register from the value in the arg1 register, store in arg1 register |
SUBMM | memory location | memory location | Subtract the value in arg2 memory location to the value in arg1 memory location, store in arg1 memory location |
SUBMR | memory location | register location | Subtract the value in arg2 register from the value in the arg1 memory location, store in arg1 memory location |
SUBMI | memory location | immediate value | Subtract the immediate value of arg2 from the value of arg1 memory location, store in arg1 memory location |
SUBMN | memory location | indirect register | Subtract the value in the value stored in the value of arg2's register from the value of the arg1 memory location, store in the arg1 memory location |
SUBNM | indirect register | memory location | Subtract the value in the arg2 memory location from the value of the value of arg2's register, store in the arg1 indirect register |
SUBNI | indirect register | immediate value | Subtract the the immediate value of arg2 from the value in the value of arg1's register, store in the arg1 indirect register |
SUBNN | indirect register | indirect register | Subtract the value in the value of arg2's register from the value in the value of arg1's register, store in the arg1 indirect register |
CISC Instruction | Argument 1 | Argument 2 | Description |
---|---|---|---|
MULTRM | register location | memory location | Multiply the value in arg1 register with the value in arg2 memory location, store in arg1 register |
MULTRR | register location | register location | Multiply the value in the arg1 register with the value in the arg2 register, store in arg1 register |
MULTRI | register location | immediate value | Multiply value in the arg1 register with the immediate value of arg2, store in arg1 register |
MULTRN | register location | indirect register | Multiply value in the arg1 register with the value stored in the value of arg2's register, store in arg1 register |
MULTMM | memory location | memory location | Multiply the value in arg1 memory location with the value in arg2 memory location, store in arg1 memory location |
MULTMR | memory location | register location | Multiply the value in arg1 memory location with the value in arg2 register, store in arg1 memory location |
MULTMI | memory location | immediate value | Multiply the value in arg1 memory location with the immediate value of arg2, store in arg1 memory location |
MULTMN | memory location | indirect register | Multiply the value in arg1 memory location with the value stored in the value of arg2's register, store in the arg1 memory location |
MULTNM | indirect register | memory location | Multiply the value in the value of arg1's register with the memory location, store in the arg1 indirect register |
MULTNI | indirect register | immediate value | Multiply the value in the value of arg1's register with the immediate value of arg2, store in the arg1 indirect register |
MULTNN | indirect register | indirect register | Multiply the value in the value of arg1's register with the value in the value of arg2's register, store in the arg1 indirect register |
CISC Instruction | Argument 1 | Argument 2 | Description |
---|---|---|---|
INCR | register location | dummy argument | Increment the value in the arg1 register by 1, store in arg1 register |
INCM | memory location | dummy argument | Increment the value in the arg1 memory location by 1, store in arg1 register |
DECR | register location | dummy argument | Decrement the value in the arg1 register by 1, store in arg1 register |
DECM | memory location | dummy argument | Decrement the value in the arg1 memory location by 1, store in arg1 register |
CISC Instruction | Argument 1 | Argument 2 | Description |
---|---|---|---|
SWAPRR | register location | register location | Swap the value in arg1 register with value in arg2 register |
SWAPMM | memory location | memory location | Swap the value in arg1 memory location with the value in the arg2 memory location |
SWAPRM | register location | memory location | Swap the the value in arg1 register location with the value in the arg2 memory location |
CISC Instruction | Argument 1 | Argument 2 | Description |
---|---|---|---|
ANDRM | register location | memory location | And the value in the arg1 register location with the value in the arg2 memory location, store in arg1 register |
ANDRR | register location | register location | And the value in the arg1 register with the value in the arg2 register, store in the arg1 register |
ANDRI | register location | immediate value | And the value in the arg1 register with the immediate value of arg2, store in the arg1 register |
ANDMM | memory location | memory location | And the value in the arg1 memory location with the value in the arg2 memory location, store in the arg1 register |
ANDMR | memory location | register location | And the value in the arg1 memory location with the value in the arg2 register, store in the arg1 register |
ANDMI | memory location | immediate value | And the value in the arg1 memory location with the immediate value of arg2, store in the arg1 register |
ORRM | register location | memory location | Or the value in the arg1 register location with the value in the arg2 memory location, store in arg1 register |
ORRR | register location | register location | Or the value in the arg1 register with the value in the arg2 register, store in the arg1 register |
ORRI | register location | immediate value | Or the value in the arg1 register with the immediate value of arg2, store in the arg1 register |
ORMM | memory location | memory location | Or the value in the arg1 memory location with the value in the arg2 memory location, store in the arg1 register |
ORMR | memory location | register location | Or the value in the arg1 memory location with the value in the arg2 register, store in the arg1 register |
ORMI | memory location | immediate value | Or the value in the arg1 memory location with the immediate value of arg2, store in the arg1 register |
NOTR | register location | dummy argument | NOT the value of the arg1 register, store in the arg1 register |
NOTM | memory location | dummy argument | NOT the value of the arg1 memory location, store in the arg1 register |
XORRM | register location | memory location | XOR the value in the arg1 register location with the value in the arg2 memory location, store in arg1 register |
XORRR | register location | register location | XOR the value in the arg1 register with the value in the arg2 register, store in the arg1 register |
XORRI | register location | immediate value | XOR the value in the arg1 register with the immediate value of arg2, store in the arg1 register |
XORMM | memory location | memory location | XOR the value in the arg1 memory location with the value in the arg2 memory location, store in the arg1 register |
XORMR | memory location | register location | XOR the value in the arg1 memory location with the value in the arg2 register, store in the arg1 register |
XORMI | memory location | immediate value | XOR the value in the arg1 memory location with the immediate value of arg2, store in the arg1 register |
CISC Instruction | Argument 1 | Argument 2 | Description |
---|---|---|---|
EQRM | register location | memory location | Test to see if the value in the arg1 register and the value in the arg2 memory location are equal. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
EQRR | register location | register location | Test to see if the value in the arg1 register and the value in the arg2 register location are equal. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
EQRI | register location | immediate value | Test to see if the value in the arg1 register and the value in the immediate value in arg2 are equal. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
EQMM | memory location | memory location | Test to see if the value in the arg1 memory location and the value in the arg2 memory location are equal. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
EQMR | memory location | register location | Test to see if the value in the arg1 memory location and the value in the arg2 register location are equal. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
EQMI | memory location | immediate value | Test to see if the value in the arg1 memory location and the immediate value of arg2 are equal. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
GRTRM | register location | memory location | Test to see if the value in the arg1 register is greater than the value in the arg2 memory location. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
GRTRR | register location | register location | Test to see if the value in the arg1 register is greater than the value in the arg2 register location. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
GRTRI | register location | immediate value | Test to see if the value in the arg1 register is greater than the value in the immediate value in arg2. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
GRTMM | memory location | memory location | Test to see if the value in the arg1 memory location is greater than the value in the arg2 memory location. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
GRTMR | memory location | register location | Test to see if the value in the arg1 memory location is greater than the value in the arg2 register location. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
GRTMI | memory location | immediate value | Test to see if the value in the arg1 memory location is greater than the immediate value of arg2. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
GRERM | register location | memory location | Test to see if the value in the arg1 register is greater than or equal to the value in the arg2 memory location. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
GRERR | register location | register location | Test to see if the value in the arg1 register is greater than or equal tothe value in the arg2 register location. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
GRERI | register location | immediate value | Test to see if the value in the arg1 register is greater than or equal to the value in the immediate value in arg2. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
GREMM | memory location | memory location | Test to see if the value in the arg1 memory location is greater than or equal to the value in the arg2 memory location. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
GREMR | memory location | register location | Test to see if the value in the arg1 memory location is greater than or equal to the value in the arg2 register location. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
GREMI | memory location | immediate value | Test to see if the value in the arg1 memory location is greater than or equal to the immediate value of arg2. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
LSTRM | register location | memory location | Test to see if the value in the arg1 register is less than the value in the arg2 memory location. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
LSTRR | register location | register location | Test to see if the value in the arg1 register is less than the value in the arg2 register location. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
LSTRI | register location | immediate value | Test to see if the value in the arg1 register is less than the value in the immediate value in arg2. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
LSTMM | memory location | memory location | Test to see if the value in the arg1 memory location is less than the value in the arg2 memory location. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
LSTMR | memory location | register location | Test to see if the value in the arg1 memory location is less than the value in the arg2 register location. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
LSTMI | memory location | immediate value | Test to see if the value in the arg1 memory location is less than the immediate value of arg2. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
LSERM | register location | memory location | Test to see if the value in the arg1 register is less than or equal to the value in the arg2 memory location. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
LSERR | register location | register location | Test to see if the value in the arg1 register is less than or equal to the value in the arg2 register location. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
LSERI | register location | immediate value | Test to see if the value in the arg1 register is less than or equal to the value in the immediate value in arg2. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
LSEMM | memory location | memory location | Test to see if the value in the arg1 memory location is less than or equal to the value in the arg2 memory location. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
LSEMR | memory location | register location | Test to see if the value in the arg1 memory location is less than or equal to the value in the arg2 register location. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
LSEMI | memory location | immediate value | Test to see if the value in the arg1 memory location is less than or equal to the immediate value of arg2. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
NEQRM | register location | memory location | Test to see if the value in the arg1 register and the value in the arg2 memory location are not equal. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
NEQRR | register location | register location | Test to see if the value in the arg1 register and the value in the arg2 register location are not equal. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
NEQRI | register location | immediate value | Test to see if the value in the arg1 register and the value in the immediate value in arg2 are not equal. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
NEQMM | memory location | memory location | Test to see if the value in the arg1 memory location and the value in the arg2 memory location are not equal. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
NEQMR | memory location | register location | Test to see if the value in the arg1 memory location and the value in the arg2 register location are not equal. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
NEQMI | memory location | immediate value | Test to see if the value in the arg1 memory location and the immediate value of arg2 are not equal. If so, store MAXINTVALUE in arg1, else store 0 in arg1 |
CISC Instruction | Argument 1 | Argument 2 | Description |
---|---|---|---|
JUMPUM | dummy argument | memory location | Unconditionally jumps to the instuction that is the value in the arg2 memory location |
JUMPUR | dummy argument | register location | Unconditionally jumps to the instruction that is the value in the arg2 reigster location |
JUMPUI | dummy argument | immediate value | Unconditionally jumps to the arg2 instruction |
JUMPUN | dummy argument | indirect register | Unconditionally jumps to the instruction that is the value of the value in the arg2 register |
JUMPTRM | register location | memory location | If the value in arg1 register is true, jump to the instuction that is the value in the arg2 memory location |
JUMPTRR | register location | register location | If the value in arg1 register is true, jump to the instruction that is the value in arg2 register |
JUMPTRI | register location | immediate value | If the value in arg1 register is true, jump to the arg2 instruction |
JUMPTRN | register location | indirect register | If the value in arg1 register is true, jump to the instruction that is the value of the value in arg2 register |
JUMPTMM | memory location | memory location | If the value in arg1 memory location is true, jump to the instruction that is the value of arg2 memory location |
JUMPTMR | memory location | register location | If the value in arg1 memory location is true, jump to the instruction that is the value of arg2 register |
JUMPTMI | memory location | immediate value | If the value in arg1 memory location is true, jump to the arg2 instruction |
JUMPTMN | memory location | indirect register | If the value in arg1 memory location is true, jump to the instruction that is the value of the value in arg2 register. |
JUMPFRM | register location | memory location | If the value in arg1 register is false, jump to the instruction that is the value of arg2 memory location |
JUMPFRR | register location | register location | If the value in arg1 register is false, jump to the instruction that is the value of arg2 register |
JUMPFRI | register location | immediate value | If the value in arg1 register is false, jump to the arg2 instruction |
JUMPFRN | register location | indirect register | If the value in arg1 register is false, jump to the instruction that is the value of the value in arg2 register |
JUMPFMM | memory location | memory location | If the value in arg1 memory location is false, jump to the instruction that is the value of the arg2 memory location |
JUMPFMR | memory location | register location | If the value in arg1 memory location is false, jump to the instruction that is the value in arg2 register |
JUMPFMI | memory location | immediate value | If the value in arg1 memory location is false, jump to the arg2 instruction |
JUMPFMN | memory location | indirect register | If the value in arg1 memory location is false, jump to the instruction that is the value of the value in arg2 register |
JUMPNRM | register location | memory location | If the value in arg1 register is negative, jump to the instruction that is the value in arg2 memory location |
JUMPNRR | register location | register location | If the value in arg1 register is negative, jump to the instruction that is the value in arg2 register location |
JUMPNRI | register location | immediate value | If the value in arg1 register is negative, jump to the arg2 instruction |
JUMPNRN | register location | indirect register | If the value in arg1 register is negative, jump to the instruction that is the value of the value in arg2 register |
JUMPNMM | memory location | memory location | If the value in arg1 memory location is negative, jump to the instruction that is the value in arg2 memory location |
JUMPNMR | memory location | register location | If the value in arg1 memory location is negative, jump to the instruction that is the value in arg2 register |
JUMPNMI | memory location | immediate value | If the value in arg1 memory location is negative, jump to the arg2 instruction |
JUMPNMN | memory location | indirect register | If the value in arg1 memory location is negative, jump to the instruction that is the value of the value in arg2 register |
All of the risc instructions are passed 2 arguments
RISC Instruction | Description |
---|---|
LOAD | Loads value in arg2 into register[arg1] |
LOADI | Loads immediate value of arg2 into register[arg1] |
STORE | Stores value in arg1 to memory location arg2 |
ADD | Adds value in arg1 and value in arg2, stores result in register[arg1] |
MULT | Multipies value in arg1 and value in arg2, stores result in register[arg1] |
NEG | Negates value in arg1 |
JUMPNZ | Jump if not zero |
AND | ANDs value in arg1 and value in arg2, stores result in register[arg1] |
OR | ORs value in arg1 and value arg2, stores result in register[arg1] |
NOT | NOTs value in arg1, stores result in register[arg1] |
EQUAL | If value of arg1 is equal to value of arg2, register[arg1]is 1, otherwise 0 |
LST | If value of arg1 is less than value of arg2, register[arg1] is 1, otherwise 0 |
WRITELN | Outputs a newline |
WRITE | Outputs value of arg1 |
Our CPU code is here.
Our Example CISC algorithms and RISC programs are here.
We Love Doing Engin Labs Together! Yay for having fun!