diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-09-01 23:13:54 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-09-01 23:13:54 +0900 |
| commit | dfea2b35c962740c701ebc2151067ce6fb155e78 (patch) | |
| tree | 6d7160083502a6e7f7de9bd531b5194b13630790 /src/codegen.c | |
| parent | 394899b2d7e75b7a922d3a402abc8f85a82b031c (diff) | |
| download | ducc-dfea2b35c962740c701ebc2151067ce6fb155e78.tar.gz ducc-dfea2b35c962740c701ebc2151067ce6fb155e78.tar.zst ducc-dfea2b35c962740c701ebc2151067ce6fb155e78.zip | |
feat: implement bitwise AND and bitwise XOR operators
Diffstat (limited to 'src/codegen.c')
| -rw-r--r-- | src/codegen.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/codegen.c b/src/codegen.c index d66574f..9aa9a77 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -180,8 +180,12 @@ static void codegen_binary_expr(CodeGen* g, AstNode* ast, GenMode gen_mode) { fprintf(g->out, " cqo\n"); fprintf(g->out, " idiv rdi\n"); fprintf(g->out, " mov rax, rdx\n"); + } else if (ast->node_op == TokenKind_and) { + fprintf(g->out, " and rax, rdi\n"); } else if (ast->node_op == TokenKind_or) { fprintf(g->out, " or rax, rdi\n"); + } else if (ast->node_op == TokenKind_xor) { + fprintf(g->out, " xor rax, rdi\n"); } else if (ast->node_op == TokenKind_lshift) { fprintf(g->out, " mov rcx, rdi\n"); fprintf(g->out, " shl rax, cl\n"); |
