Skip to content

Commit 591c567

Browse files
committed
fix: not code generation is wrong
1 parent f666178 commit 591c567

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/codegen.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,11 @@ static void gen(Node const* node)
6666

6767
if (node->ty == '!') {
6868
gen(node->lhs);
69+
printf(" xor rdx, rdx\n");
6970
printf(" pop rax\n");
7071
printf(" cmp rax, 0\n");
71-
printf(" sete al\n");
72-
printf(" push rax\n");
72+
printf(" sete dl\n");
73+
printf(" push rdx\n");
7374

7475
return;
7576
}

test.sh

+1
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,4 @@ try 0 "void* foo(size_t n) { return n - 1229801703532086340; } int main(void)
216216
try 0 "int main(void) { void** data = 0; return data + 0;}"
217217
try 8 "int main(void) { void** data = 0; size_t i = 1; return data + i++;}"
218218
try 1 "int main(void) { int i = 1 != 0 && 1 < 10; return i; }"
219+
try 10 "int main(void) { char* q = 10576963; if (!q) {return 0;} return 10; }"

0 commit comments

Comments
 (0)