diff options
| author | Mustafa Quraish <[email protected]> | 2022-02-07 23:07:57 -0500 |
|---|---|---|
| committer | Mustafa Quraish <[email protected]> | 2022-02-08 02:07:18 -0500 |
| commit | e5f2fac8c5ae5a1b74335816836872c2e24904e6 (patch) | |
| tree | ed131049d39320967d8d18f65749c08ebb2f79a0 /compiler/codegen.cup | |
| parent | Mark bootstrap files as binary in `.gitattributes` (diff) | |
| download | cup-master.tar.xz cup-master.zip | |
Diffstat (limited to 'compiler/codegen.cup')
| -rw-r--r-- | compiler/codegen.cup | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/compiler/codegen.cup b/compiler/codegen.cup index 67a401c..bf20a8b 100644 --- a/compiler/codegen.cup +++ b/compiler/codegen.cup @@ -142,6 +142,21 @@ fn generate_expr_into_rax(node: Node*) { emit_asm(" pop rbx\n"); emit_asm(" sub rax, rbx\n"); + } else if (node.typ == AST_LSHIFT) { + generate_expr_into_rax(node.d.binary.rhs); + emit_asm(" push rax\n"); + generate_expr_into_rax(node.d.binary.lhs); + emit_asm(" pop rcx\n"); + emit_asm(" shl rax, cl\n"); + + + } else if (node.typ == AST_RSHIFT) { + generate_expr_into_rax(node.d.binary.rhs); + emit_asm(" push rax\n"); + generate_expr_into_rax(node.d.binary.lhs); + emit_asm(" pop rcx\n"); + emit_asm(" shr rax, cl\n"); + } else if (node.typ == AST_DIV) { generate_expr_into_rax(node.d.binary.rhs); emit_asm(" push rax\n"); |