In the video, where he does push constant 17, he shows
@17
D=A
@SP
A=M
M=D
@SP
M=M+1
Notice that needs 3 A instructions. But, if you pay attention, during the demo, with BasicTest.vm, for push constant 10, his implementation is :
@10
D=A
@SP
AM=M+1
A=A-1
M=D
Saved an instruction! Nice. Ha - did you think Stuxnet was easy to build my man? Truly, since he scrolls down in his ASM file, he's given you the implementation of "pop argument 2" and so it should be okay to put that down here - but that would be mean :)
Not that they're hard to implement, but he's given you add and sub as well :) Both cute, and using 5 instructions each. Booleans are super easy. For the conditionals, you'll have to use the jumps to conditionally write the appropriate value to the stack.
No comments:
Post a Comment