From e1de8fc36f11ac932707c7113eb4bf3ebc4b1f74 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 3 Aug 2025 13:19:40 +0900 Subject: feat: support short type --- codegen.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'codegen.c') 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"); -- cgit v1.2.3-70-g09d2