added v2.0
This commit is contained in:
1
07_Operating_System/05_Array_Test/Array.jack
Symbolic link
1
07_Operating_System/05_Array_Test/Array.jack
Symbolic link
@@ -0,0 +1 @@
|
||||
../Array.jack
|
2
07_Operating_System/05_Array_Test/ArrayTest.cmp
Normal file
2
07_Operating_System/05_Array_Test/ArrayTest.cmp
Normal file
@@ -0,0 +1,2 @@
|
||||
|RAM[8000]|RAM[8001]|RAM[8002]|RAM[8003]|
|
||||
| 222 | 122 | 100 | 10 |
|
15
07_Operating_System/05_Array_Test/ArrayTest.tst
Normal file
15
07_Operating_System/05_Array_Test/ArrayTest.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/ArrayTest/ArrayTest.tst
|
||||
|
||||
load,
|
||||
output-file ArrayTest.out,
|
||||
compare-to ArrayTest.cmp,
|
||||
output-list RAM[8000]%D2.6.1 RAM[8001]%D2.6.1 RAM[8002]%D2.6.1 RAM[8003]%D2.6.1;
|
||||
|
||||
repeat 1000000 {
|
||||
vmstep;
|
||||
}
|
||||
|
||||
output;
|
1
07_Operating_System/05_Array_Test/GPIO.jack
Symbolic link
1
07_Operating_System/05_Array_Test/GPIO.jack
Symbolic link
@@ -0,0 +1 @@
|
||||
../GPIO.jack
|
40
07_Operating_System/05_Array_Test/Main.jack
Normal file
40
07_Operating_System/05_Array_Test/Main.jack
Normal file
@@ -0,0 +1,40 @@
|
||||
// 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/ArrayTest/Main.jack
|
||||
|
||||
/** Test program for the OS Array class. */
|
||||
class Main {
|
||||
|
||||
/** Performs several Array manipulations. */
|
||||
function void main() {
|
||||
var Array r; // stores test results
|
||||
var Array a, b, c;
|
||||
|
||||
let r = 4107;
|
||||
|
||||
let a = Array.new(3);
|
||||
let a[2] = 222;
|
||||
let r[0] = a[2]; // RAM[4107] = 222
|
||||
|
||||
let b = Array.new(3);
|
||||
let b[1] = a[2] - 100;
|
||||
let r[1] = b[1]; // RAM[4108] = 122
|
||||
|
||||
let c = Array.new(500);
|
||||
let c[499] = a[2] - b[1];
|
||||
let r[2] = c[499]; // RAM[4109] = 100
|
||||
|
||||
do a.dispose();
|
||||
do b.dispose();
|
||||
|
||||
let b = Array.new(3);
|
||||
let b[0] = c[499] - 90;
|
||||
let r[3] = b[0]; // RAM[4110] = 10
|
||||
|
||||
do c.dispose();
|
||||
do b.dispose();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
18
07_Operating_System/05_Array_Test/Makefile
Normal file
18
07_Operating_System/05_Array_Test/Makefile
Normal file
@@ -0,0 +1,18 @@
|
||||
all: jack vm asm bin sim
|
||||
|
||||
jack:
|
||||
../../tools/JackCompiler/JackCompiler.pyc ./
|
||||
vm:
|
||||
../../tools/VMTranslator/VMTranslator.pyc ./
|
||||
asm:
|
||||
../../tools/Assembler/assembler.pyc out.asm
|
||||
bin:
|
||||
../../tools/AsciiToBin.py out.hack
|
||||
sim:
|
||||
cp out.hack ../00_HACK/ROM.hack
|
||||
upload:
|
||||
iceprogduino -o 64k -w out.bin
|
||||
clean:
|
||||
rm -f *.vm *.asm *.hack *.bin *~
|
||||
|
||||
.PHONY: all clean
|
1
07_Operating_System/05_Array_Test/Memory.jack
Symbolic link
1
07_Operating_System/05_Array_Test/Memory.jack
Symbolic link
@@ -0,0 +1 @@
|
||||
../Memory.jack
|
24
07_Operating_System/05_Array_Test/Readme.md
Normal file
24
07_Operating_System/05_Array_Test/Readme.md
Normal file
@@ -0,0 +1,24 @@
|
||||
## Array.jack
|
||||
|
||||
Represents an array.
|
||||
In the Jack language, arrays are instances of the Array class. Once declared, the array entries can be accessed using the usual syntax arr[i]. Each array entry can hold a primitive data type as well as any object type. Different array entries can have different data types.
|
||||
|
||||
***
|
||||
|
||||
### Project
|
||||
|
||||
* Implement `Array.jack`
|
||||
|
||||
* Test in simulation:
|
||||
|
||||
```
|
||||
$ cd 05_Array_Test
|
||||
$ make
|
||||
$ cd ../00_HACK
|
||||
$ apio clean
|
||||
$ apio sim
|
||||
```
|
||||
|
||||
* Check the content of special function register DEBUG0--DEBUG4.
|
||||
|
||||

|
31
07_Operating_System/05_Array_Test/Readme.md.backup
Normal file
31
07_Operating_System/05_Array_Test/Readme.md.backup
Normal file
@@ -0,0 +1,31 @@
|
||||
## Array.jack
|
||||
Represents an array.
|
||||
In the Jack language, arrays are instances of the Array class. Once declared, the array entries can be accessed using the usual syntax arr[i]. Each array entry can hold a primitive data type as well as any object type. Different array entries can have different data types.
|
||||
|
||||
### function Array new(int size)
|
||||
Constructs a new Array of the given size.
|
||||
|
||||
if (~(size>0)){
|
||||
do Sys.error(3);
|
||||
}
|
||||
return Memory.alloc(size);
|
||||
}
|
||||
|
||||
/** Disposes this array. */
|
||||
method void dispose() {
|
||||
do Memory.deAlloc(this);
|
||||
***
|
||||
## Project
|
||||
* Implement `Array.jack`
|
||||
* Test in simulation:
|
||||
```
|
||||
$ cd 05_Array_Test
|
||||
$ make
|
||||
$ cd ../00_HACK
|
||||
$ apio clean
|
||||
$ apio sim
|
||||
```
|
||||
|
||||
* Check the content of special function register DEBUG0--DEBUG4.
|
||||
|
||||

|
1
07_Operating_System/05_Array_Test/Sys.jack
Symbolic link
1
07_Operating_System/05_Array_Test/Sys.jack
Symbolic link
@@ -0,0 +1 @@
|
||||
../Sys.jack
|
1
07_Operating_System/05_Array_Test/UART.jack
Symbolic link
1
07_Operating_System/05_Array_Test/UART.jack
Symbolic link
@@ -0,0 +1 @@
|
||||
../UART.jack
|
BIN
07_Operating_System/05_Array_Test/array.png
Normal file
BIN
07_Operating_System/05_Array_Test/array.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 88 KiB |
Reference in New Issue
Block a user