simulator that follows the ISA defined next. It is written in C++ and may use the Qt framework for the GUI.
The ISA has 4 general purpose registers, R0, R1, R2, and R3. The ISA also has a program counter register.
The ISA has a stack that is 4096 bytes in size. The stack pointer register points to the top of the stack.
The ISA has a shared memory to store code and data, with a variable size. direct access to memory is permitted.
The ALU is a 32-bit ALU that supports the following operations:
line comments are started with a !
and end at the end of the line.
Load register reg1 with the contents of either the contents of reg2, or the memory var or a constant
const. Memory regions loads (load into a variable, for instance) are NOT ALLOWED.
There can be indirect loads, for instance LDA R1, R2
will load the contents of the memory address
Store the contents of reg or const into the memory var.
Register regions stores (store into a Register,for instance t0) are NOT ALLOWED.
There can be indirect stores, for instance STR R1, R2
will store the contents of R1 into the memory address
Push the contents of reg/var or const into the top of the stack.
Pop the contents of the top of the stack into reg/var. Storing into Memory regions is NOT ALLOWED.
Check the value of the element at the top of the stack
Check the value of the element at the nth position from the top of stack
The logical operations are the following: there cannot be result stored in a memory region.
Perform a Logical AND between reg1 and reg2 or const and store the result in reg1.
Perform a Logical OR between reg1 and reg2 or const and store the result in reg1.
Perform a Logical NOT on reg1 and store the result in reg1.
The arithmetical operations are the following: there cannot be result stored in a memory region.
Perform an addition between reg1 and reg2/var or const and store the result in reg1.
Perform a subtraction between reg1 and reg2/var or const and store the result in reg1.
Perform a multiplication between reg1 and reg2/var or const and store the result in reg1.
Perform a division between reg1 and reg2/var or const and store the result in reg1.
Perform a modulo between reg1 and reg2/var or const and store the result in reg1. The operation is defined as first argument is the modulo of the second argument.
Increment the contents of reg1 by 1.
Decrement the contents of reg1 by 1.
Branch to the label if reg1 is equal to reg2 or const.
Branch to the label if reg1 is not equal to reg2 or const.
Branch to the label if reg1 is bigger than reg2 or const.
Branch to the label if reg1 is smaller than reg2 or const.
Jump to the label.
Halt the execution of the program.
Shift the contents of reg1 to the right by the amount of bits specified in const.
Shift the contents of reg1 to the left by the amount of bits specified in const.