From 77eb521af4b001f27e79c7df84f99970a0b3bc2e Mon Sep 17 00:00:00 2001 From: Goren Barak Date: Fri, 15 Dec 2023 17:15:08 -0500 Subject: [PATCH] Math works (more)! --- src/codegen/fasm.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/codegen/fasm.rs b/src/codegen/fasm.rs index 01b14b5..a682f50 100644 --- a/src/codegen/fasm.rs +++ b/src/codegen/fasm.rs @@ -77,6 +77,8 @@ impl FasmCodegen { }, // If the operator is division. MathOperator::OP_DIV => { + asm_start.push_str("\tpop r10\n"); + asm_start.push_str("\tpop r11\n"); asm_start.push_str("\tmov rax, r10\n"); asm_start.push_str("\txor rdx, rdx\n"); asm_start.push_str("\tidiv r11\n"); @@ -85,6 +87,8 @@ impl FasmCodegen { }, // If the operators is subtraction. MathOperator::OP_SUB => { + asm_start.push_str("\tpop r10\n"); + asm_start.push_str("\tpop r11\n"); asm_start.push_str("\tsub r10, r11\n"); asm_start.push_str("\tmov rax, r10\n"); @@ -93,6 +97,8 @@ impl FasmCodegen { }, // If the operator is modulo. MathOperator::OP_MOD => { + asm_start.push_str("\tpop r10\n"); + asm_start.push_str("\tpop r11\n"); asm_start.push_str("\tmov rax, r10\n"); asm_start.push_str("\txor rdx, rdx\n"); asm_start.push_str("\tidiv r11\n");