-
Notifications
You must be signed in to change notification settings - Fork 44
Fixing Bugs with MARIE.js Explained
This page talks about how to go about solving multiple important and critical issues found in MARIE.js
This bug occurs when the user tries to jump to an address beyond the address range of 0 to 4096.
For example, the following code would break the simulator, and crash the webpage.
LoadI X
X, DEC 4097
All we did was check if the values passed to PC
is beyond the address range or not:
if(target == "pc"){
if(this[target] < 0 || this[target] >= 4096){
throw new MarieSimError("RuntimeError", ...);
}
}
from marie.js: RegSet
Well, the second biggest bug solved was the calculation overflow bug, this occurs when the number goes beyond the range. So to determine the range you have to do the following:
- Calculate the amount of numbers between the range (0 to HEX FFFF), there are
16^4
possibilities which give 65536 numbers - Find the 'middle point', this gives us
65536/2
which is32768
- We know that MARIE uses 2nd-Complement, which means that between -32768 to 0 and 0 to 32767 are calculable. Using the concept from bug #148, we can apply it here to
if(this[target] < -32768 || this[target] > 32767){
throw new MarieSimError("RuntimeError", ...);
}
from marie.js: RegSet
Copyright © 2018 Jason Nguyen, Saurabh Joshi, Eric Jiang, Felix Salim, Guido Tack, Monash University
Documentation
MARIE Instructions Set with Opcode
Register Transfer Language (RTL)
More Reading
The Essentials of Computer Organization and Architecture-Chapter 4.2
Tutorials
MARIE.js Documentation