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");