mirror of
https://github.com/soconnor0919/eceg431.git
synced 2025-12-11 14:44:43 -05:00
project12 - add files
This commit is contained in:
34
12/MathTest/Main.jack
Normal file
34
12/MathTest/Main.jack
Normal file
@@ -0,0 +1,34 @@
|
||||
// This file is part of www.nand2tetris.org
|
||||
// and the book "The Elements of Computing Systems"
|
||||
// by Nisan and Schocken, MIT Press.
|
||||
// File name: projects/12/MathTest/Main.jack
|
||||
|
||||
// Tests the OS Math class.
|
||||
class Main {
|
||||
|
||||
// Performs various mathematical operations, using calls to the Math class methods.
|
||||
function void main() {
|
||||
var Array r; // Stores the test results;
|
||||
let r = 8000; // Base address
|
||||
|
||||
let r[0] = 2 * 3; // 6
|
||||
let r[1] = r[0] * (-30); // 6 * (-30) = -180
|
||||
let r[2] = r[1] * 100; // (-180) * 100 = -18000
|
||||
let r[3] = 1 * r[2]; // 1 * (-18000) = -18000
|
||||
let r[4] = r[3] * 0; // 0
|
||||
|
||||
let r[5] = 9 / 3; // 3
|
||||
let r[6] = (-18000) / 6; // -3000
|
||||
let r[7] = 32766 / (-32767); // (2^15 - 2) / (2^15 - 1) = 0
|
||||
|
||||
let r[8] = Math.sqrt(9); // 3
|
||||
let r[9] = Math.sqrt(32767); // 181
|
||||
|
||||
let r[10] = Math.min(345, 123); // 123
|
||||
let r[11] = Math.max(123, -345); // 123
|
||||
let r[12] = Math.abs(27); // 27
|
||||
let r[13] = Math.abs(-32767); // 32767
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
15
12/MathTest/MathTest.tst
Normal file
15
12/MathTest/MathTest.tst
Normal file
@@ -0,0 +1,15 @@
|
||||
// This file is part of www.nand2tetris.org
|
||||
// and the book "The Elements of Computing Systems"
|
||||
// by Nisan and Schocken, MIT Press.
|
||||
// File name: projects/12/MathTest/MathTest.tst
|
||||
|
||||
load,
|
||||
output-file MathTest.out,
|
||||
compare-to MathTest.cmp,
|
||||
output-list RAM[8000]%D2.6.1 RAM[8001]%D2.6.1 RAM[8002]%D2.6.1 RAM[8003]%D2.6.1 RAM[8004]%D2.6.1 RAM[8005]%D2.6.1 RAM[8006]%D2.6.1 RAM[8007]%D2.6.1 RAM[8008]%D2.6.1 RAM[8009]%D2.6.1 RAM[8010]%D2.6.1 RAM[8011]%D2.6.1 RAM[8012]%D2.6.1 RAM[8013]%D2.6.1;
|
||||
|
||||
repeat 1000000 {
|
||||
vmstep;
|
||||
}
|
||||
|
||||
output;
|
||||
Reference in New Issue
Block a user