Add solutions for part 1
This commit is contained in:
106
projects/08/FunctionCalls/StaticsTest/Class1.asm
Normal file
106
projects/08/FunctionCalls/StaticsTest/Class1.asm
Normal file
@@ -0,0 +1,106 @@
|
||||
// Unsupported Function
|
||||
|
||||
// push argument 0
|
||||
@0
|
||||
D = A
|
||||
@ARG
|
||||
A = M
|
||||
A = D + A
|
||||
D = M
|
||||
// ^ D = *(LCL + index)
|
||||
@SP
|
||||
A = M
|
||||
M = D
|
||||
@SP
|
||||
M = M + 1
|
||||
// ^ push D
|
||||
|
||||
// pop static Class1.0
|
||||
@SP
|
||||
A = M
|
||||
A = A - 1
|
||||
D = M
|
||||
@SP
|
||||
M = M - 1
|
||||
// ^ pop into D
|
||||
@Class1.0
|
||||
M = D
|
||||
// ^ Class1.0 = D
|
||||
|
||||
// push argument 1
|
||||
@1
|
||||
D = A
|
||||
@ARG
|
||||
A = M
|
||||
A = D + A
|
||||
D = M
|
||||
// ^ D = *(LCL + index)
|
||||
@SP
|
||||
A = M
|
||||
M = D
|
||||
@SP
|
||||
M = M + 1
|
||||
// ^ push D
|
||||
|
||||
// pop static Class1.1
|
||||
@SP
|
||||
A = M
|
||||
A = A - 1
|
||||
D = M
|
||||
@SP
|
||||
M = M - 1
|
||||
// ^ pop into D
|
||||
@Class1.1
|
||||
M = D
|
||||
// ^ Class1.1 = D
|
||||
|
||||
// push constant 0
|
||||
@0
|
||||
D = A
|
||||
@SP
|
||||
A = M
|
||||
M = D
|
||||
@SP
|
||||
M = M + 1
|
||||
|
||||
// Unsupported Return
|
||||
|
||||
// Unsupported Function
|
||||
|
||||
// push static Class1.0
|
||||
@Class1.0
|
||||
D = M
|
||||
// ^ D = Class1.0
|
||||
@SP
|
||||
A = M
|
||||
M = D
|
||||
@SP
|
||||
M = M + 1
|
||||
// ^ push from D
|
||||
|
||||
// push static Class1.1
|
||||
@Class1.1
|
||||
D = M
|
||||
// ^ D = Class1.1
|
||||
@SP
|
||||
A = M
|
||||
M = D
|
||||
@SP
|
||||
M = M + 1
|
||||
// ^ push from D
|
||||
|
||||
// sub
|
||||
@SP
|
||||
A = M
|
||||
A = A - 1
|
||||
A = A - 1
|
||||
D = M
|
||||
A = A + 1
|
||||
D = D - M
|
||||
A = A - 1
|
||||
M = D
|
||||
@SP
|
||||
M = M - 1
|
||||
|
||||
// Unsupported Return
|
||||
|
||||
Reference in New Issue
Block a user