diff --git a/boot.c b/boot.c index 1a67fac..ff6b4ee 100644 --- a/boot.c +++ b/boot.c @@ -1697,15 +1697,17 @@ void parse_for() { } void parse_do_while() { + int body_label = next_label(); int cont_label = next_label(); int break_label = next_label(); asm_push_label(break_label, cont_label); - asm_label(cont_label); + asm_label(body_label); parse_stmt(); // body expect_token(TOKEN_WHILE); expect_token(TOKEN_PAREN_LEFT); + asm_label(cont_label); int cond = parse_expr(); - asm_bnez(cond, cont_label); + asm_bnez(cond, body_label); expect_token(TOKEN_PAREN_RIGHT); asm_label(break_label); asm_pop_label();