diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-08-03 13:19:40 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-08-15 10:06:21 +0900 |
| commit | e1de8fc36f11ac932707c7113eb4bf3ebc4b1f74 (patch) | |
| tree | 65c0a362dc9343b09a6e452d5526e39da834b986 /codegen.c | |
| parent | 185778aa3ae35252ae992f12a9dfc39a4eab5758 (diff) | |
| download | ducc-e1de8fc36f11ac932707c7113eb4bf3ebc4b1f74.tar.gz ducc-e1de8fc36f11ac932707c7113eb4bf3ebc4b1f74.tar.zst ducc-e1de8fc36f11ac932707c7113eb4bf3ebc4b1f74.zip | |
feat: support short type
Diffstat (limited to 'codegen.c')
| -rw-r--r-- | codegen.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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"); |
