##Firefly computing system
To use this software, you must have python3
and tkinter
installed.
sudo apt-get install python3 python3tk
python3 Jarvis.py
Ultron.py
is the high level language compiler (High level language -> VM intermediate format).VirtualMachine.py
is the virtual machine translator (VM commands -> Assembly commands).Jarvis.py
is the assembler and CPU simulator (Assembly commands -> binary).
The test code and some skeleton files are provided by the book The Elements of Computing Systems by Noam Nisan and Shimon Schocken (MIT Press).
The tecs
directory contains all of the source code included with the book.
The OS
directory contains the operating system files. The files ending in .jack are the high level language code, including:
-
Array.jack
- Create new arrays with
var myArray = Array.new(size)
and destroy them withmyArray.destroy()
.
- Create new arrays with
-
Keyboard.jack
keyPressed()
Returns an ASCII code of the current key being pressed.readChar()
Reads the next character from the keyboard, waits until a key is pressed and then released, echoes the key to the screen, and returns the value of the pressed key.readLine(String message)
Prints amessage
on the screen, reads the next line of input until a newline character, and returns its value.readInt(String message)
Prints amessage
on the screen, reads the next line of input until a newline character, and returns its value as an integer, until the first non numeric character.
-
Math.jack
twoToThe(x)
Returns 2^x
.abs(x)
Returns the absolute value of ``x.multiply(x, y)
Returns the product ofx
andy
.bit(x, j)
Returnstrue
of thej
-th bit ofx
is1
andfalse
otherwise.divide(x, y)
Returns the integer part ofx/y
. Returns0
ify > x
. Returns-1
for overflow.xor(x, y)
Returnsx
XORy
.sqrt(x)
Returns the square root ofx
.max(x, y)
Returns the greater number ofx
andy
.min(x, y)
Returns the smaller number ofx
andy
.mod(n, base)
Returns the remainder of the division ofn
/base
-
Memory.jack
peek(address)
Returns the value of memory at locationaddress
.poke(address, value)
Sets the value of memory locationaddress
tovalue
.alloc(size)
Allocates a block of memory of sizesize
and returns a reference to its base address.deAlloc(object)
De-allocates a given object and frees its space.
-
Output.jack
moveCursor(i, j)
Moves the cursor to thej
th column of thei
th row.print(String s)
Prints an anonymousString
and then destroys it.printLoc()
Prints the location of the cursor to the screenprintChar(c)
Printsc
at the cursor location and advances the cursor one column forward.printString(s)
Printss
starting at the cursor location and advances the cursor appropriately.printInt(i)
Prints theInteger
i
at the cursor location and advances the cursor appropriately.println()
Advances the cursor to the beginning of the next line.backSpace()
Moves the cursor one column back.
-
String.jack
new(maxLength)
Constructs a newString
of maximum lengthmaxLength
.myString.dispose()
Disposes this string and frees its space.myString.length()
Returns the length of thisString
.myString.charAt(j)
Returns the character at location j. If j < 0, counts from the end of the string backwards to j.myString.setCharAt(j, c)
Sets thej
th character of this string to bec
.myString.appendChar(c)
Appends the characterc
to the end of thisString
.myString.slice(from, to)
Returns a slice of thisString
.myString.grow(n)
Grows this string byn
characters.myString.eraseLastChar()
Erases the last character in thisString
.myString.intValue()
Returns the integer value of this string until the first non-numeric character.myString.setInt(n)
Sets this string to hold a representation of the given numbern
.newLine()
Returns the newline character.backSpace()
Returns the backspace character.doubleQuote()
Returns the double quote character.
-
Sys.jack
init()
This method is called automatically upon bootstrapping, initializing all.init()
methods of all other classes in the OS.halt()
Halts the execution of the processor, hopefully without catching anything on fire.wait(duration)
Waits approximatelyduration
milliseconds and then returns.error(code)
Prints out the given error code and then halts.breakpoint()
An empty function to be used to inject breakpoints while debugging.
Also, this directory will contain Main.jack
which houses the main()
method, which is the beginning point of any application defined code.