mirror of
https://github.com/captn3m0/nand2tetris.git
synced 2024-09-28 13:23:01 +00:00
423 lines
5.3 KiB
Plaintext
423 lines
5.3 KiB
Plaintext
function Draw.Grid 2
|
|
push constant 0
|
|
pop local 0
|
|
label WHILE_EXP0
|
|
push local 0
|
|
push constant 3
|
|
lt
|
|
not
|
|
if-goto WHILE_END0
|
|
push constant 32
|
|
push local 0
|
|
call Math.multiply 2
|
|
push constant 16
|
|
call Math.multiply 2
|
|
pop local 1
|
|
push local 1
|
|
call Draw.Border 1
|
|
pop temp 0
|
|
push local 1
|
|
push constant 1
|
|
add
|
|
call Draw.Border 1
|
|
pop temp 0
|
|
push local 1
|
|
push constant 2
|
|
add
|
|
call Draw.Border 1
|
|
pop temp 0
|
|
push local 0
|
|
push constant 1
|
|
add
|
|
pop local 0
|
|
goto WHILE_EXP0
|
|
label WHILE_END0
|
|
push constant 0
|
|
return
|
|
function Draw.Border 1
|
|
push constant 16384
|
|
push argument 0
|
|
add
|
|
pop local 0
|
|
push local 0
|
|
push constant 0
|
|
add
|
|
push constant 1
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 32
|
|
add
|
|
push constant 32767
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 64
|
|
add
|
|
push constant 32767
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 96
|
|
add
|
|
push constant 32767
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 128
|
|
add
|
|
push constant 32767
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 160
|
|
add
|
|
push constant 32767
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 192
|
|
add
|
|
push constant 32767
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 224
|
|
add
|
|
push constant 32767
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 256
|
|
add
|
|
push constant 32767
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 288
|
|
add
|
|
push constant 32767
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 320
|
|
add
|
|
push constant 32767
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 352
|
|
add
|
|
push constant 32767
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 384
|
|
add
|
|
push constant 32767
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 416
|
|
add
|
|
push constant 32767
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 448
|
|
add
|
|
push constant 32767
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 480
|
|
add
|
|
push constant 1
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push constant 0
|
|
return
|
|
function Draw.Location 0
|
|
push constant 32
|
|
push argument 0
|
|
call Math.multiply 2
|
|
push constant 16
|
|
call Math.multiply 2
|
|
push argument 1
|
|
add
|
|
return
|
|
function Draw.DrawX 1
|
|
push argument 0
|
|
push argument 1
|
|
call Draw.Location 2
|
|
pop local 0
|
|
push local 0
|
|
call Draw.X 1
|
|
pop temp 0
|
|
push constant 0
|
|
return
|
|
function Draw.DrawO 1
|
|
push argument 0
|
|
push argument 1
|
|
call Draw.Location 2
|
|
pop local 0
|
|
push local 0
|
|
call Draw.O 1
|
|
pop temp 0
|
|
push constant 0
|
|
return
|
|
function Draw.X 1
|
|
push constant 16384
|
|
push argument 0
|
|
add
|
|
pop local 0
|
|
push local 0
|
|
push constant 0
|
|
add
|
|
push constant 1
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 32
|
|
add
|
|
push constant 32767
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 64
|
|
add
|
|
push constant 20467
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 96
|
|
add
|
|
push constant 18403
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 128
|
|
add
|
|
push constant 25543
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 160
|
|
add
|
|
push constant 29071
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 192
|
|
add
|
|
push constant 31807
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 224
|
|
add
|
|
push constant 31807
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 256
|
|
add
|
|
push constant 31807
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 288
|
|
add
|
|
push constant 31807
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 320
|
|
add
|
|
push constant 29071
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 352
|
|
add
|
|
push constant 25543
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 384
|
|
add
|
|
push constant 18403
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 416
|
|
add
|
|
push constant 20467
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 448
|
|
add
|
|
push constant 32767
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 480
|
|
add
|
|
push constant 1
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push constant 0
|
|
return
|
|
function Draw.O 1
|
|
push constant 16384
|
|
push argument 0
|
|
add
|
|
pop local 0
|
|
push local 0
|
|
push constant 0
|
|
add
|
|
push constant 1
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 32
|
|
add
|
|
push constant 32767
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 64
|
|
add
|
|
push constant 28687
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 96
|
|
add
|
|
push constant 24583
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 128
|
|
add
|
|
push constant 20467
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 160
|
|
add
|
|
push constant 20467
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 192
|
|
add
|
|
push constant 20467
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 224
|
|
add
|
|
push constant 20467
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 256
|
|
add
|
|
push constant 20467
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 288
|
|
add
|
|
push constant 20467
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 320
|
|
add
|
|
push constant 20467
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 352
|
|
add
|
|
push constant 20467
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 384
|
|
add
|
|
push constant 24583
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 416
|
|
add
|
|
push constant 28687
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 448
|
|
add
|
|
push constant 32767
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push local 0
|
|
push constant 480
|
|
add
|
|
push constant 1
|
|
neg
|
|
call Memory.poke 2
|
|
pop temp 0
|
|
push constant 0
|
|
return
|