diff --git a/codegen.c b/codegen.c index 819aaae..c6adc34 100644 --- a/codegen.c +++ b/codegen.c @@ -1843,6 +1843,10 @@ void codegen_generate_goto_stmt(struct node *node) { asm_push("jmp label_%s", node->stmt._goto.label->sval); } +void codegen_generate_label(struct node *node) { + asm_push("label_%s:", node->label.name->sval); +} + void codegen_generate_statement(struct node *node, struct history *history) { switch (node->type) { case NODE_TYPE_VARIABLE: @@ -1900,6 +1904,10 @@ void codegen_generate_statement(struct node *node, struct history *history) { case NODE_TYPE_STATEMENT_GOTO: codegen_generate_goto_stmt(node); break; + + case NODE_TYPE_LABEL: + codegen_generate_label(node); + break; } codegen_discard_unused_stack();