white label
This commit is contained in:
parent
e425464aab
commit
a850aeed63
3 changed files with 13 additions and 13 deletions
7
boot.c
7
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);
|
||||
|
|
|
@ -2,6 +2,7 @@ int printf(char* format, ...);
|
|||
|
||||
int main() {
|
||||
int i;
|
||||
printf("hello for 10 times\n");
|
||||
for (i = 0;
|
||||
i < 10;
|
||||
++i)
|
||||
|
|
|
@ -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('''
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title><%title%></title>
|
||||
<title>${title}</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
|
@ -90,25 +90,25 @@ template = '''
|
|||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1><%title%></h1>
|
||||
<h1>${title}</h1>
|
||||
</header>
|
||||
<div class="container">
|
||||
<div class="column">
|
||||
<h2>Source Code</h2>
|
||||
<pre>
|
||||
<code><%src%></code>
|
||||
<code>${src}</code>
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<div class="column">
|
||||
<h2>Assembly</h2>
|
||||
<pre>
|
||||
<code><%asm%></code>
|
||||
<code>${asm}</code>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
'''
|
||||
''')
|
||||
|
||||
print(template.replace("<%title%>", title).replace("<%src%>", src).replace("<%asm%>", asm))
|
||||
print(template.substitute(title=title, src=src, asm=asm))
|
Loading…
Add table
Add a link
Reference in a new issue