added v2.0
This commit is contained in:
1
07_Operating_System/08_StdIO_Test/Array.jack
Symbolic link
1
07_Operating_System/08_StdIO_Test/Array.jack
Symbolic link
@@ -0,0 +1 @@
|
||||
../Array.jack
|
1
07_Operating_System/08_StdIO_Test/GPIO.jack
Symbolic link
1
07_Operating_System/08_StdIO_Test/GPIO.jack
Symbolic link
@@ -0,0 +1 @@
|
||||
../GPIO.jack
|
70
07_Operating_System/08_StdIO_Test/Main.jack
Normal file
70
07_Operating_System/08_StdIO_Test/Main.jack
Normal file
@@ -0,0 +1,70 @@
|
||||
// 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/KeyboardTest/Main.jack
|
||||
|
||||
/** Test program for the OS Keyboard class. */
|
||||
class Main {
|
||||
|
||||
/** Gets input from the user and verifies its contents. */
|
||||
function void main() {
|
||||
var char c, key;
|
||||
var String s;
|
||||
var int i;
|
||||
var boolean ok;
|
||||
|
||||
do StdIO.printString("StdIO test:");
|
||||
do StdIO.println();
|
||||
|
||||
let ok = false;
|
||||
while (~ok) {
|
||||
do StdIO.printString("Please press the number '3': ");
|
||||
let c = UART.readChar();
|
||||
|
||||
do StdIO.println();
|
||||
|
||||
if (c = 51) {
|
||||
do StdIO.printString("ok");
|
||||
do StdIO.println();
|
||||
let ok = true;
|
||||
}
|
||||
}
|
||||
|
||||
let ok = false;
|
||||
do StdIO.printString("readLine test:");
|
||||
do StdIO.println();
|
||||
do StdIO.printString("(Verify echo and usage of 'backspace')");
|
||||
do StdIO.println();
|
||||
while (~ok) {
|
||||
let s = StdIO.readLine("Please type 'JACK' and press enter: ");
|
||||
|
||||
if (s.length() = 4) {
|
||||
if ((s.charAt(0) = 74) & (s.charAt(1) = 65) & (s.charAt(2) = 67) & (s.charAt(3) = 75)) {
|
||||
do StdIO.printString("ok");
|
||||
do StdIO.println();
|
||||
let ok = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let ok = false;
|
||||
do StdIO.printString("readInt test:");
|
||||
do StdIO.println();
|
||||
do StdIO.printString("(Verify echo and usage of 'backspace')");
|
||||
do StdIO.println();
|
||||
while (~ok) {
|
||||
let i = StdIO.readInt("Please type '-32123' and press enter: ");
|
||||
|
||||
if (i = (-32123)) {
|
||||
do StdIO.printString("ok");
|
||||
do StdIO.println();
|
||||
let ok = true;
|
||||
}
|
||||
}
|
||||
|
||||
do StdIO.println();
|
||||
do StdIO.printString("Test completed successfully");
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
18
07_Operating_System/08_StdIO_Test/Makefile
Normal file
18
07_Operating_System/08_StdIO_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/08_StdIO_Test/Math.jack
Symbolic link
1
07_Operating_System/08_StdIO_Test/Math.jack
Symbolic link
@@ -0,0 +1 @@
|
||||
../Math.jack
|
1
07_Operating_System/08_StdIO_Test/Memory.jack
Symbolic link
1
07_Operating_System/08_StdIO_Test/Memory.jack
Symbolic link
@@ -0,0 +1 @@
|
||||
../Memory.jack
|
29
07_Operating_System/08_StdIO_Test/Readme.md
Normal file
29
07_Operating_System/08_StdIO_Test/Readme.md
Normal file
@@ -0,0 +1,29 @@
|
||||
## StdIO.jack
|
||||
|
||||
A library of functions for text based input and output over UART.
|
||||
|
||||
***
|
||||
|
||||
### Project
|
||||
|
||||
* Implement `StdIO.jack`.
|
||||
|
||||
* Run `StdIO_Test` in real hardware on iCE40HX1K-EVB using a terminal program connected to UART.
|
||||
|
||||
* Compare your terminal output with:
|
||||
|
||||
```
|
||||
StdIO test:
|
||||
Please press the number '3':
|
||||
ok
|
||||
readLine test:
|
||||
(Verify echo and usage of 'backspace')
|
||||
Please type 'JACK' and press enter: JACK
|
||||
ok
|
||||
readInt test:
|
||||
(Verify echo and usage of 'backspace')
|
||||
Please type '-32123' and press enter: -32123
|
||||
ok
|
||||
|
||||
Test completed successfully
|
||||
```
|
35
07_Operating_System/08_StdIO_Test/Readme.md.backup
Normal file
35
07_Operating_System/08_StdIO_Test/Readme.md.backup
Normal file
@@ -0,0 +1,35 @@
|
||||
## StdIO.jack
|
||||
A library of functions for textual input and output over UART.
|
||||
|
||||
### function void printString(String s)
|
||||
Print the String s to UART_TX and disposes the String s.
|
||||
### function void printInt(int i)
|
||||
Prints the decimal representation of i to UART_TX
|
||||
### function void println()
|
||||
Prints the new line character to UART_TX
|
||||
### function int readInt(String message)
|
||||
Displays the message on the screen, disposes the message, reads from UART_RX the entered text until a newline character is detected, echoes the text to UART_TX, and returns its integer value (until the first non-digit character in the entered text is detected). Also handles user backspaces.
|
||||
### function String readLine(String message)
|
||||
Sends the message to UART_TX, reads from UART_RX the entered text until a newline character is detected, echoes the text to the UART_TX, and returns its value. Also handles user backspaces.
|
||||
***
|
||||
## Project
|
||||
* Implement `StdIO.jack`.
|
||||
* Run String_Test in real hardware on iCE40HX1K-EVB using a terminal program connected to UART.
|
||||
|
||||
* Compare your terminal output with:
|
||||
|
||||
```
|
||||
StdIO test:
|
||||
Please press the number '3':
|
||||
ok
|
||||
readLine test:
|
||||
(Verify echo and usage of 'backspace')
|
||||
Please type 'JACK' and press enter: JACK
|
||||
ok
|
||||
readInt test:
|
||||
(Verify echo and usage of 'backspace')
|
||||
Please type '-32123' and press enter: -32123
|
||||
ok
|
||||
|
||||
Test completed successfully
|
||||
```
|
1
07_Operating_System/08_StdIO_Test/StdIO.jack
Symbolic link
1
07_Operating_System/08_StdIO_Test/StdIO.jack
Symbolic link
@@ -0,0 +1 @@
|
||||
../StdIO.jack
|
1
07_Operating_System/08_StdIO_Test/String.jack
Symbolic link
1
07_Operating_System/08_StdIO_Test/String.jack
Symbolic link
@@ -0,0 +1 @@
|
||||
../String.jack
|
1
07_Operating_System/08_StdIO_Test/Sys.jack
Symbolic link
1
07_Operating_System/08_StdIO_Test/Sys.jack
Symbolic link
@@ -0,0 +1 @@
|
||||
../Sys.jack
|
1
07_Operating_System/08_StdIO_Test/UART.jack
Symbolic link
1
07_Operating_System/08_StdIO_Test/UART.jack
Symbolic link
@@ -0,0 +1 @@
|
||||
../UART.jack
|
Reference in New Issue
Block a user