aboutsummaryrefslogtreecommitdiff
path: root/compiler/codegen.cup
diff options
context:
space:
mode:
authorMustafa Quraish <[email protected]>2022-02-07 23:07:57 -0500
committerMustafa Quraish <[email protected]>2022-02-08 02:07:18 -0500
commite5f2fac8c5ae5a1b74335816836872c2e24904e6 (patch)
treeed131049d39320967d8d18f65749c08ebb2f79a0 /compiler/codegen.cup
parentMark bootstrap files as binary in `.gitattributes` (diff)
downloadcup-master.tar.xz
cup-master.zip
[cup] Add `>>` and `<<` operators, `fork()` buildin and `SYS_execve`HEADmaster
Diffstat (limited to 'compiler/codegen.cup')
-rw-r--r--compiler/codegen.cup15
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");