PMIS 0.4 Manual
Table of contents
About PMIS
Welcome to PMIS - an interpreted simulator of a simulator - a "spimulator", if you like! It takes a few assembly language instructions from the MIPS instruction set, and uses Javascript to process programs you can write yourself within the PMIS integrated development environment.
It has not been tested on any browsers less than Netscape 6.2 and Internet Explorer 6.
Advantages over SPIM
The user has/can:
- the ability to immediately edit register and memory values
- the choice of a little-endian or a big-endian machine
- almost a full IDE
- two assembly language memories
- instant access to all PMIS' memory values - the whole 400 bytes!
- instruction set buttons which show the correct format of the instruction
- view register output in hexadecimal, binary, or decimal
- view instruction output in hexadecimal, binary, or decimal
- a demonstration library of programs
- no need to learn pre-processor directives - can just start typing instructions and see what they do
- comments can be multi-line - very convenient when debugging!
- PMIS calculates PC-relative addresses correctly (unlike SPIM).
Disadvantages
- only twenty-two instructions
- no overflow detection
- no input/output console (not necessary for GCO2812)
- no program counter (although while stepping through a program, PMIS will advise the user of the last instruction executed)
- no trap handler (although it will catch infinite loops within a range specified by the user)
- is ALMOST consistent in behaviour across Netscape and Internet Explorer (exceptions are only in window functions, not processing)
- comments are handled differently, requiring one further character to delimit
Writing a program
Either:
Type PMIS instructions into the text box on the left of "PMIS 0.4".
Or:
Click on the PMIS instruction buttons to insert the correct syntax of the desired expression, and then overwrite the question marks. (The instructions always insert at the end, not the cursor position).
Comments
To insert a comment, surround it with "#", i.e.:
addi $t0, $r0, 1 #initialise to 1#
addi $t1, $zero, 2 #initialise to 2#
beq $t2, $t4, skip1 #make decision#
Clearing the text box
If you wish to delete the current text, click "Clear".
Assembly language text box memories
There are also two memories available to store the contents of the assembly language text box. The "Store ?" buttons store the program and clear the box; the "Recall ?" buttons retrieve the contents from memory. (PS, the memory is volatile!)
Demonstration program
A demonstration program can be recalled by clicking on "Demo". In addition to this, this manual contains some demonstration programs which can be run by cutting and pasting into PMIS' text box.
Running a program
Push the button marked, "Start Spimulating". If the program runs correctly, "Start Spimulating" will change to "Run again?" (using current register values). This is the only feedback the user will receive in response to the program completing all instructions.
If the program is not successful, an error box may advise you of any syntax errors, and where to fix them in your code.
If any errors cannot be identified by the syntax checker, or the program cannot terminate correctly (writing data throughout instruction memory, for example), the "Run again" message should not appear.
[back to top]
Stepping through a program
Push the button marked "Step through prog" until the end of the program is reached. The face of the button will change to show the hexadecimal value in memory of the last instruction executed. If you wish to quit a program before stepping through completely, please reset the registers before starting another program.
[back to top]
Resetting
Reset mem & regs
Pushing this will clear the registers, resetting the stack pointer to the end of memory, and clear the memory contents including the program. It used to set the control panel values back to default, and the text box to blank, but this proved to be a pain.
Reset regs only
This just clears the registers, but also resets the stack pointer to the
end of memory.
[back to top]
Control Panel
Memory addressing mode
This enables the user to choose between the program running in little-endian
or big-endian mode. If you run the demonstration program "Little-endian versus big-endian" once in each mode, the difference will become instantly clear.
Base of displayed output
All output from a program is displayed in the 32 registers in hexadecimal.
However, by selecting "Binary" or "Decimal", a pop-up box will show
all 32 registers in that base after each step (in step mode) or at the
successful end of a program run.
Max. iterations
There is no trap-handler in PMIS. In the event of any deliberate or inadvertent infinite loops, after this number of iterations (the default is 100,000), the program will simply abort with a warning. Increase the number in this box if your program needs it.
Both Netscape and Internet Explorer are smart enough to know that
a big loop is happening, and may advise you of this asking you if you
wish to terminate the script before the program has finished running. If
this happens, and your program is valid, hit "Yes" to continue.
[back to top]
Instruction representation
The 400 bytes of "memory" in PMIS also holds the program instructions. For convenience, the default representation is in assembly language, complete with the labels. These can also be viewed in hex (The word "instruction" is automatically appended so instructions can be differentiated from the rest of the contents of the memory). Binary output can also be selected, which is useful when writing or testing in machine language.
(Yes, it IS inconsistent displaying instructions in one format and data memory in another...)
Just remember that PMIS' memory addresses start at 0, unlike SPIM. This means that you will not be able to compare PMIS output with SPIM output for instructions which utilise labels such as "j", or "jal" without adding in the difference manually.
SPIM does NOT calculate PC-relative addresses correctly - it works them out according to the offset from the CURRENT instruction, not PC+4. (PMIS uses PC+4, in case that wasn't obvious!)
[back to top]
- If the "Start Spimulating" or "Run again?" buttons click in and stay in, it is probable there is a large loop occurring - it may take about a minute or so before the loop counter gets to the figure set in the "Max. iterations" box in the Control Panel - just wait!
- There MUST be a space between a label's semicolon and the following instruction for the interpreter to function correctly
- Speaking of labels, I neglected to allow for multiple labels at the one address - this only affects the instruction display in memory, not the actual functioning. To get around this, insert a "nop" (no operation) in between the two labels, i.e.:
outer: nop
inner:
bne $t0, $t0, inner
bne $t0, $t0, outer
- "addi" will only load -32,768 to 32,767 into a register. Use "ori" to load 0 to 65,635. In case you're wondering why "addiu" is not present, it's because its range is only the same as "addi", despite it having a suffix of "u". (See p230, Patterson & Hennessy).
[back to top]
User defined programs
In order to save any programs you have written in the PMIS IDE, you'll need to cut and paste from the text box into a text file, and save that on your PC for future use.
[back to top]
Demonstration programs
Click for new window
[back to top]
PMIS instruction set
Click for new window
Things to do
- I neglected to allow for multiple labels at the one address - this only affects the instruction display in memory, not the actual functioning. Although this is annoying, it's going to have to wait until the next version of PMIS. To get around it, see PMIS hints and tips above
- This version of PMIS stores the "compiled" instructions in a separate array; this means that if you overwrite the instruction representation in memory, it will still function perfectly - this makes for "safer" programs, but not better programmers...
[back to top]
Last updated on 27 November, 2003 by Paul Morris