Math works (more)!

master
Goren Barak 2023-12-15 17:15:08 -05:00
parent ac72d8add8
commit 77eb521af4
1 changed files with 6 additions and 0 deletions

View File

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