- Linux with nodejs, npm and git packages installed (sudo apt-get update & sudo apt-get install -y nodejs npm git)
- CREATOR repository cloned (git clone https://github.com/creatorsim/creator.git)
- The necessary nodejs packages installed (cd creator; npm install terser jshint colors yargs readline-sync)
You can use the following commands to install the prerequisites:
sudo apt-get update & sudo apt-get install nodejs npm git -y
git clone https://github.com/creatorsim/creator.git
cd creator
npm install terser jshint colors yargs readline-sync
- To compile with creator we have to use the -a and -s flags:
./creator.sh -a <architercture file> -s <assembly file>
Example:
./creator.sh -a architecture/MIPS-32.json -s examples/MIPS/example2.txt
Output:
CREATOR
-------
version: 3.1
website: https://creatorsim.github.io/
[examples/MIPS/example2.txt]
[Architecture] Architecture 'architecture/MIPS-32.json' loaded successfully.
[Library] Without library
[Compile] Code 'examples/MIPS/example2.txt' compiled successfully.
[Execute] Executed successfully.
[FinalState] cr[PC]:0x20; ir[t0,8]:0xa; ir[t1,9]:0xd; ir[t2,10]:0x2d; ir[t3,11]:0x21; ir[t4,12]:0x17; ir[t5,13]:0xc; ir[t6,14]:0x441; ir[t7,15]:0x53; keyboard[0x0]:''; display[0x0]:'';
- First, we save the final state execution into a file we have to use the -a, -s and -o flags in this way:
./creator.sh -a <architercture file> -s <assembly file> -o min > <output file>
Example:
./creator.sh -a ./architecture/MIPS_32.json -s ./examples/MIPS/example2.txt -o min > output.txt
cat output.txt
Output:
cr[PC]:0x20; ir[t0,8]:0xa; ir[t1,9]:0xd; ir[t2,10]:0x2d; ir[t3,11]:0x21; ir[t4,12]:0x17; ir[t5,13]:0xc; ir[t6,14]:0x441; ir[t7,15]:0x53; keyboard[0x0]:''; display[0x0]:'';
- Then, we compare the final state execution and the state saved on file by using the -r flag:
./creator.sh -a <architercture file> -s <assembly file> -o min -r <compare file>
Example:
./creator.sh -a ./architecture/MIPS_32.json -s ./examples/MIPS/example2.txt -o min -r output.txt
Output:
Equals
The output.txt is the final state we want to compare with, so we can remove the elements of the final state that are not part of the checking.
- To show the command line help, just use the -h switch:
./creator.sh -h
Output:
CREATOR
-------
version: 3.1
website: https://creatorsim.github.io/
Usage: creator.sh -a <file name> -s <file name>
Usage: creator.sh -h
Options:
--version Show version number [boolean]
-a, --architecture Architecture file [string] [required] [default: ""]
-s, --assembly Assembly file [string] [required] [default: ""]
-d, --directory Assemblies directory [string] [default: ""]
-l, --library Assembly library file [string] [default: ""]
-r, --result Result file to compare with [string] [default: ""]
--describe Help on element [string] [default: ""]
--maxins Maximum number of instructions to be executed
[string] [default: "1000000"]
-o, --output Define output format [string] [default: "normal"]
--color Colored output [boolean] [default: false]
-h, --help Show help [boolean]
Examples:
./creator.sh To show examples.
- How to make a line break?
A line break cannot be printed as a string (print_string), it has to be printed as a character (print_char). The following code can be used to print it:
li a0 '\n' # Loads the ASCII value of the character into the register a0
li a7 11 # print_char syscall
ecall
- Can you put two labels consecutively?
It is not allowed. The instructions can only be associated with one label. If a label is placed after another, the simulator will display a compilation error.
Example of incorrect two consecutive labels:
label1:
label2: li t0 1
Alternative correct code with the same functionality:
label1: li t0 1
label2: add t2 t1 t0
syscall