aboutsummaryrefslogtreecommitdiffhomepage
path: root/codegen.c
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-08-03 13:19:40 +0900
committernsfisis <nsfisis@gmail.com>2025-08-15 10:06:21 +0900
commite1de8fc36f11ac932707c7113eb4bf3ebc4b1f74 (patch)
tree65c0a362dc9343b09a6e452d5526e39da834b986 /codegen.c
parent185778aa3ae35252ae992f12a9dfc39a4eab5758 (diff)
downloadducc-e1de8fc36f11ac932707c7113eb4bf3ebc4b1f74.tar.gz
ducc-e1de8fc36f11ac932707c7113eb4bf3ebc4b1f74.tar.zst
ducc-e1de8fc36f11ac932707c7113eb4bf3ebc4b1f74.zip
feat: support short type
Diffstat (limited to 'codegen.c')
-rw-r--r--codegen.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/codegen.c b/codegen.c
index 51254dc..7ca5fe7 100644
--- a/codegen.c
+++ b/codegen.c
@@ -93,7 +93,8 @@ void codegen_push_expr(const char* reg, int size) {
printf(" movsx %s, BYTE PTR [%s]\n", reg, reg);
printf(" push %s\n", reg);
} else if (size == 2) {
- unimplemented();
+ printf(" movsx %s, WORD PTR [%s]\n", reg, reg);
+ printf(" push %s\n", reg);
} else if (size == 4) {
printf(" movsxd %s, DWORD PTR [%s]\n", reg, reg);
printf(" push %s\n", reg);
@@ -226,6 +227,11 @@ void codegen_assign_expr(CodeGen* g, AstNode* ast) {
printf(" pop rax\n");
printf(" mov BYTE PTR [rax], dil\n");
printf(" push rdi\n");
+ } else if (sizeof_lhs == 2) {
+ printf(" pop rdi\n");
+ printf(" pop rax\n");
+ printf(" mov WORD PTR [rax], di\n");
+ printf(" push rdi\n");
} else if (sizeof_lhs == 4) {
printf(" pop rdi\n");
printf(" pop rax\n");