From d8ad916c80ce1e1dcfeabb8441896e94f7f00568 Mon Sep 17 00:00:00 2001 From: Frederick Yin Date: Mon, 22 Aug 2022 17:33:07 +0800 Subject: hack-vm: optimize pop by one instruction --- projects/hack-vm/memory.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'projects/hack-vm') 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 is one of static, temp and pointer POP_FIXED_ASM = """@SP -M=M-1 -A=M +AM=M-1 D=M @{addr} M=D -- cgit v1.2.3