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) {
|
void asm_branch(char* op, int rs1, int label) {
|
||||||
char* rs1_name = trivialize(rs1, REG_T0);
|
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) {
|
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) {
|
void asm_j(int label) {
|
||||||
printf(" j L%d\n", label);
|
printf(" j .L%d\n", label);
|
||||||
}
|
}
|
||||||
|
|
||||||
int next_label_id = 0;
|
int next_label_id = 0;
|
||||||
|
@ -1041,7 +1041,7 @@ int next_label() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int asm_label(int label) {
|
int asm_label(int label) {
|
||||||
printf("L%d:\n", label);
|
printf(".L%d:\n", label);
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1993,7 +1993,6 @@ void parse_top_level() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void dump_string_table() {
|
void dump_string_table() {
|
||||||
printf("# string table: \n");
|
|
||||||
printf(".data\n");
|
printf(".data\n");
|
||||||
for (int i = 0; i < string_lut_size; ++i) {
|
for (int i = 0; i < string_lut_size; ++i) {
|
||||||
printf(".LC%d: .string \"", i);
|
printf(".LC%d: .string \"", i);
|
||||||
|
|
|
@ -2,6 +2,7 @@ int printf(char* format, ...);
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
int i;
|
int i;
|
||||||
|
printf("hello for 10 times\n");
|
||||||
for (i = 0;
|
for (i = 0;
|
||||||
i < 10;
|
i < 10;
|
||||||
++i)
|
++i)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import sys
|
import sys
|
||||||
import html
|
import html
|
||||||
|
from string import Template
|
||||||
|
|
||||||
src = ''
|
src = ''
|
||||||
asm = ''
|
asm = ''
|
||||||
|
@ -16,9 +17,8 @@ for line in sys.stdin:
|
||||||
style += 1
|
style += 1
|
||||||
style %= 5
|
style %= 5
|
||||||
flip = False
|
flip = False
|
||||||
elif line.startswith("# string table: "):
|
elif line.startswith(".L") or line.startswith(".data") or line.startswith(".text"):
|
||||||
asm += line
|
asm += line
|
||||||
break
|
|
||||||
else:
|
else:
|
||||||
asm += decorate(line)
|
asm += decorate(line)
|
||||||
flip = True
|
flip = True
|
||||||
|
@ -29,13 +29,13 @@ for line in sys.stdin:
|
||||||
title = 'RVBTCC Code Gen Demo'
|
title = 'RVBTCC Code Gen Demo'
|
||||||
|
|
||||||
|
|
||||||
template = '''
|
template = Template('''
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title><%title%></title>
|
<title>${title}</title>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
font-family: Arial, sans-serif;
|
font-family: Arial, sans-serif;
|
||||||
|
@ -90,25 +90,25 @@ template = '''
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
<h1><%title%></h1>
|
<h1>${title}</h1>
|
||||||
</header>
|
</header>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<h2>Source Code</h2>
|
<h2>Source Code</h2>
|
||||||
<pre>
|
<pre>
|
||||||
<code><%src%></code>
|
<code>${src}</code>
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<h2>Assembly</h2>
|
<h2>Assembly</h2>
|
||||||
<pre>
|
<pre>
|
||||||
<code><%asm%></code>
|
<code>${asm}</code>
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</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