diff --git a/04_semantics_and_running/main.py b/04_semantics_and_running/main.py index 6689b51..a3552e6 100644 --- a/04_semantics_and_running/main.py +++ b/04_semantics_and_running/main.py @@ -780,11 +780,9 @@ def compile_ast(node: ASTnode, compile_data: CompileData) -> None: elif node.value == '<': compile_data.code.append(Instruction('cmpq', [register, '%rax'])) compile_data.code.append(Instruction('setl', ['%al'])) - compile_data.code.append(Instruction('movzbq', ['%al', '%rax'])) elif node.value == '=': compile_data.code.append(Instruction('cmpq', [register, '%rax'])) compile_data.code.append(Instruction('sete', ['%al'])) - compile_data.code.append(Instruction('movzbq', ['%al', '%rax'])) else: assert False # If both operands are dates, divide result by number of seconds in a day @@ -841,7 +839,7 @@ def compile_ast(node: ASTnode, compile_data: CompileData) -> None: # compile condition compile_ast(node.child_condition, compile_data) - compile_data.code.append(Instruction('testq', ['%rax', '%rax'])) + compile_data.code.append(Instruction('testb', ['%al', '%al'])) compile_data.code.append(Instruction('jz', [label_loop])) case 'do_unless' | 'unless_expression': label_true = compile_data.get_label() @@ -849,7 +847,7 @@ def compile_ast(node: ASTnode, compile_data: CompileData) -> None: # compile condition compile_ast(node.child_condition, compile_data) - compile_data.code.append(Instruction('testq', ['%rax', '%rax'])) + compile_data.code.append(Instruction('testb', ['%al', '%al'])) compile_data.code.append(Instruction('jnz', [label_true])) # compile false statements