mirror of
https://github.com/soconnor0919/nand2tetris-zed.git
synced 2026-02-05 00:06:41 -05:00
Fix HDL and Hack Assembly syntax highlighting and queries
- Fixed HDL highlights query syntax error with #match? predicate - Replaced #match? with #any-of? for exact string matching - Fixed Hack Assembly outline query invalid field name - Improved HDL syntax highlighting with comprehensive patterns - Added HDL bracket matching for all syntax types - Fixed XML scope mismatch from text.xml to source.xml - Enhanced outline queries for better code navigation
This commit is contained in:
26
test-examples/Add.asm
Normal file
26
test-examples/Add.asm
Normal file
@@ -0,0 +1,26 @@
|
||||
// Computes R0 = 2 + 3
|
||||
@2
|
||||
D=A
|
||||
@3
|
||||
D=D+A
|
||||
@0
|
||||
M=D
|
||||
|
||||
// Loop example with labels
|
||||
@i
|
||||
M=1
|
||||
(LOOP)
|
||||
@i
|
||||
D=M
|
||||
@10
|
||||
D=D-A
|
||||
@END
|
||||
D;JGT
|
||||
|
||||
@i
|
||||
M=M+1
|
||||
@LOOP
|
||||
0;JMP
|
||||
(END)
|
||||
@END
|
||||
0;JMP
|
||||
5
test-examples/And.cmp
Normal file
5
test-examples/And.cmp
Normal file
@@ -0,0 +1,5 @@
|
||||
| a | b |out|
|
||||
| 0 | 0 | 0 |
|
||||
| 0 | 1 | 0 |
|
||||
| 1 | 0 | 0 |
|
||||
| 1 | 1 | 1 |
|
||||
13
test-examples/And.hdl
Normal file
13
test-examples/And.hdl
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* And gate:
|
||||
* out = 1 if (a == 1 and b == 1)
|
||||
* 0 otherwise
|
||||
*/
|
||||
CHIP And {
|
||||
IN a, b;
|
||||
OUT out;
|
||||
|
||||
PARTS:
|
||||
Nand(a=a, b=b, out=nandOut);
|
||||
Not(in=nandOut, out=out);
|
||||
}
|
||||
23
test-examples/CPU.tst
Normal file
23
test-examples/CPU.tst
Normal file
@@ -0,0 +1,23 @@
|
||||
load CPU.hdl,
|
||||
output-file CPU.out,
|
||||
compare-to CPU.cmp,
|
||||
|
||||
output-list time%S1.3.1 instruction%B0.16.0 pc%D0.5.0;
|
||||
|
||||
set instruction %B0011000000111001, // @12345
|
||||
tick,
|
||||
output;
|
||||
tock,
|
||||
output;
|
||||
|
||||
set instruction %B1110110000010000, // D=A
|
||||
tick,
|
||||
output;
|
||||
tock,
|
||||
output;
|
||||
|
||||
repeat 10 {
|
||||
ticktock;
|
||||
}
|
||||
|
||||
output;
|
||||
24
test-examples/Math.jack
Normal file
24
test-examples/Math.jack
Normal file
@@ -0,0 +1,24 @@
|
||||
class Math {
|
||||
static Array twoToThe;
|
||||
|
||||
/** Initializes the library. */
|
||||
function void init() {
|
||||
var int i;
|
||||
let twoToThe = Array.new(16);
|
||||
let twoToThe[0] = 1;
|
||||
let i = 1;
|
||||
while (i < 16) {
|
||||
let twoToThe[i] = twoToThe[i-1] + twoToThe[i-1];
|
||||
let i = i + 1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
function int multiply(int x, int y) {
|
||||
var int sum, shiftedX;
|
||||
let sum = 0;
|
||||
let shiftedX = x;
|
||||
// Implementation details...
|
||||
return sum;
|
||||
}
|
||||
}
|
||||
32
test-examples/SimpleAdd.vm
Normal file
32
test-examples/SimpleAdd.vm
Normal file
@@ -0,0 +1,32 @@
|
||||
// Stack arithmetic operations
|
||||
push constant 7
|
||||
push constant 8
|
||||
add
|
||||
|
||||
// Memory operations
|
||||
push local 0
|
||||
push local 1
|
||||
add
|
||||
pop local 2
|
||||
|
||||
// Function definition
|
||||
function Math.multiply 2
|
||||
push constant 0
|
||||
pop local 0
|
||||
|
||||
label LOOP
|
||||
push local 1
|
||||
push constant 0
|
||||
eq
|
||||
if-goto END
|
||||
|
||||
push local 0
|
||||
push argument 0
|
||||
add
|
||||
pop local 0
|
||||
|
||||
goto LOOP
|
||||
|
||||
label END
|
||||
push local 0
|
||||
return
|
||||
Reference in New Issue
Block a user