diff options
author | Frederick Yin <fkfd@fkfd.me> | 2022-08-22 17:33:07 +0800 |
---|---|---|
committer | Frederick Yin <fkfd@fkfd.me> | 2022-08-22 17:33:07 +0800 |
commit | d8ad916c80ce1e1dcfeabb8441896e94f7f00568 (patch) | |
tree | d1438afcaba312052e16e3959ba4ebeb5289351a | |
parent | 51c8325661eab4667a11431175f12eb6a08cc36a (diff) |
hack-vm: optimize pop by one instruction
-rw-r--r-- | projects/hack-vm/memory.py | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/projects/hack-vm/memory.py b/projects/hack-vm/memory.py index ad22482..84f4a53 100644 --- a/projects/hack-vm/memory.py +++ b/projects/hack-vm/memory.py @@ -44,8 +44,7 @@ D=A @{segment} M=M+D @SP -M=M-1 -A=M +AM=M-1 D=M @{segment} A=M @@ -58,8 +57,7 @@ M=M-D # when <segment> is one of static, temp and pointer POP_FIXED_ASM = """@SP -M=M-1 -A=M +AM=M-1 D=M @{addr} M=D |