From a850aeed63991721e0ff71aa10c95d4f9904682f Mon Sep 17 00:00:00 2001 From: Yaossg Date: Mon, 10 Mar 2025 22:15:52 +0800 Subject: [PATCH] white label --- boot.c | 7 +++---- demo/for.c | 1 + transcript.py | 18 +++++++++--------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/boot.c b/boot.c index d5c87ef..03ecc60 100644 --- a/boot.c +++ b/boot.c @@ -917,7 +917,7 @@ void _asm_ri(char* op, int rd, int rs1, int imm) { void asm_branch(char* op, int rs1, int label) { char* rs1_name = trivialize(rs1, REG_T0); - printf(" %s %s, L%d\n", op, rs1_name, label); + printf(" %s %s, .L%d\n", op, rs1_name, label); } void _asm_i(char* op, int rd, char* prefix1, char* prefix2, int imm) { @@ -1032,7 +1032,7 @@ void asm_bnez(int rs1, int label) { } void asm_j(int label) { - printf(" j L%d\n", label); + printf(" j .L%d\n", label); } int next_label_id = 0; @@ -1041,7 +1041,7 @@ int next_label() { } int asm_label(int label) { - printf("L%d:\n", label); + printf(".L%d:\n", label); return label; } @@ -1993,7 +1993,6 @@ void parse_top_level() { } void dump_string_table() { - printf("# string table: \n"); printf(".data\n"); for (int i = 0; i < string_lut_size; ++i) { printf(".LC%d: .string \"", i); diff --git a/demo/for.c b/demo/for.c index 31d696c..54fc299 100644 --- a/demo/for.c +++ b/demo/for.c @@ -2,6 +2,7 @@ int printf(char* format, ...); int main() { int i; + printf("hello for 10 times\n"); for (i = 0; i < 10; ++i) diff --git a/transcript.py b/transcript.py index d83e8fa..8d0d82b 100644 --- a/transcript.py +++ b/transcript.py @@ -1,5 +1,6 @@ import sys import html +from string import Template src = '' asm = '' @@ -16,9 +17,8 @@ for line in sys.stdin: style += 1 style %= 5 flip = False - elif line.startswith("# string table: "): + elif line.startswith(".L") or line.startswith(".data") or line.startswith(".text"): asm += line - break else: asm += decorate(line) flip = True @@ -29,13 +29,13 @@ for line in sys.stdin: title = 'RVBTCC Code Gen Demo' -template = ''' +template = Template(''' - <%title%> + ${title}