-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
3,728 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
#include "output.s" | ||
|
||
.file "main.c" | ||
.option nopic | ||
.text | ||
.section .rodata | ||
.align 3 | ||
.LC0: | ||
.string "%s" | ||
.text | ||
.align 1 | ||
.globl _write_str | ||
.type _write_str, @function | ||
_write_str: | ||
addi sp,sp,-32 | ||
sd ra,24(sp) | ||
sd s0,16(sp) | ||
addi s0,sp,32 | ||
sd a0,-24(s0) | ||
ld a1,-24(s0) | ||
lui a5,%hi(.LC0) | ||
addi a0,a5,%lo(.LC0) | ||
call printf | ||
nop | ||
ld ra,24(sp) | ||
ld s0,16(sp) | ||
addi sp,sp,32 | ||
jr ra | ||
.size _write_str, .-_write_str | ||
.section .rodata | ||
.align 3 | ||
.LC1: | ||
.string "%d" | ||
.text | ||
.align 1 | ||
.globl _write_int | ||
.type _write_int, @function | ||
_write_int: | ||
addi sp,sp,-32 | ||
sd ra,24(sp) | ||
sd s0,16(sp) | ||
addi s0,sp,32 | ||
mv a5,a0 | ||
sw a5,-20(s0) | ||
lw a5,-20(s0) | ||
mv a1,a5 | ||
lui a5,%hi(.LC1) | ||
addi a0,a5,%lo(.LC1) | ||
call printf | ||
nop | ||
ld ra,24(sp) | ||
ld s0,16(sp) | ||
addi sp,sp,32 | ||
jr ra | ||
.size _write_int, .-_write_int | ||
.section .rodata | ||
.align 3 | ||
.LC2: | ||
.string "%f" | ||
.text | ||
.align 1 | ||
.globl _write_float | ||
.type _write_float, @function | ||
_write_float: | ||
addi sp,sp,-32 | ||
sd ra,24(sp) | ||
sd s0,16(sp) | ||
addi s0,sp,32 | ||
fsw fa0,-20(s0) | ||
flw fa5,-20(s0) | ||
fcvt.d.s fa5,fa5 | ||
fmv.x.d a1,fa5 | ||
lui a5,%hi(.LC2) | ||
addi a0,a5,%lo(.LC2) | ||
call printf | ||
nop | ||
ld ra,24(sp) | ||
ld s0,16(sp) | ||
addi sp,sp,32 | ||
jr ra | ||
.size _write_float, .-_write_float | ||
.section .rodata | ||
.align 3 | ||
.LC3: | ||
.string "%d" | ||
.text | ||
.align 1 | ||
.globl _read_int | ||
.type _read_int, @function | ||
_read_int: | ||
addi sp,sp,-32 | ||
sd ra,24(sp) | ||
sd s0,16(sp) | ||
addi s0,sp,32 | ||
sw zero,-20(s0) | ||
addi a5,s0,-20 | ||
mv a1,a5 | ||
lui a5,%hi(.LC3) | ||
addi a0,a5,%lo(.LC3) | ||
call __isoc99_scanf | ||
lw a5,-20(s0) | ||
mv a0,a5 | ||
ld ra,24(sp) | ||
ld s0,16(sp) | ||
addi sp,sp,32 | ||
jr ra | ||
.size _read_int, .-_read_int | ||
.align 1 | ||
.globl _read_float | ||
.type _read_float, @function | ||
_read_float: | ||
addi sp,sp,-32 | ||
sd ra,24(sp) | ||
sd s0,16(sp) | ||
addi s0,sp,32 | ||
sw zero,-20(s0) | ||
addi a5,s0,-20 | ||
mv a1,a5 | ||
lui a5,%hi(.LC2) | ||
addi a0,a5,%lo(.LC2) | ||
call __isoc99_scanf | ||
flw fa5,-20(s0) | ||
fmv.s fa0,fa5 | ||
ld ra,24(sp) | ||
ld s0,16(sp) | ||
addi sp,sp,32 | ||
jr ra | ||
.size _read_float, .-_read_float | ||
.align 1 | ||
.globl main | ||
.type main, @function | ||
main: | ||
addi sp,sp,-16 | ||
sd ra,8(sp) | ||
sd s0,0(sp) | ||
addi s0,sp,16 | ||
call _start_MAIN | ||
li a5,0 | ||
mv a0,a5 | ||
ld ra,8(sp) | ||
ld s0,0(sp) | ||
addi sp,sp,16 | ||
jr ra | ||
.size main, .-main | ||
.ident "GCC: (GNU) 8.3.0" | ||
.section .note.GNU-stack,"",@progbits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
$1 $2 | ||
/home/ntu/.local/riscv/bin/riscv64-unknown-linux-gnu-gcc -O0 -static main.S |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
typedef int INT; | ||
typedef float FLOAT; | ||
typedef int INTA[2]; | ||
typedef float FLOATA[2]; | ||
|
||
int g1; | ||
float g2; | ||
INT g3; | ||
FLOAT g4; | ||
int g5[2]; | ||
float g6[2]; | ||
INT g7[2]; | ||
FLOAT g8[2]; | ||
INTA g9; | ||
FLOATA g10; | ||
|
||
int main() { | ||
int l1; | ||
float l2; | ||
INT l3; | ||
FLOAT l4; | ||
int l5[2]; | ||
float l6[2]; | ||
INT l7[2]; | ||
FLOAT l8[2]; | ||
INTA l9; | ||
FLOATA l10; | ||
|
||
g1 = 1; | ||
g2 = 2.0; | ||
g3 = 3; | ||
g4 = 4.0; | ||
g5[0] = 5; | ||
g5[1] = 55; | ||
g6[0] = 6.0; | ||
g6[1] = 66.0; | ||
g7[0] = 7; | ||
g7[1] = 77; | ||
g8[0] = 8.0; | ||
g8[1] = 88.0; | ||
g9[0] = 9; | ||
g9[1] = 99; | ||
g10[0] = 10.0; | ||
g10[1] = 100.0; | ||
|
||
l1 = 1; | ||
l2 = 2.0; | ||
l3 = 3; | ||
l4 = 4.0; | ||
l5[0] = 5; | ||
l5[1] = 55; | ||
l6[0] = 6.0; | ||
l6[1] = 66.0; | ||
l7[0] = 7; | ||
l7[1] = 77; | ||
l8[0] = 8.0; | ||
l8[1] = 88.0; | ||
l9[0] = 9; | ||
l9[1] = 99; | ||
l10[0] = 10.0; | ||
l10[1] = 100.0; | ||
|
||
write(g1); | ||
write("\n"); | ||
write(g2); | ||
write("\n"); | ||
write(g3); | ||
write("\n"); | ||
write(g4); | ||
write("\n"); | ||
write(g5[0]); | ||
write("\n"); | ||
write(g5[1]); | ||
write("\n"); | ||
write(g6[0]); | ||
write("\n"); | ||
write(g6[1]); | ||
write("\n"); | ||
write(g7[0]); | ||
write("\n"); | ||
write(g7[1]); | ||
write("\n"); | ||
write(g8[0]); | ||
write("\n"); | ||
write(g8[1]); | ||
write("\n"); | ||
write(g9[0]); | ||
write("\n"); | ||
write(g9[1]); | ||
write("\n"); | ||
write(g10[0]); | ||
write("\n"); | ||
write(g10[1]); | ||
write("\n"); | ||
|
||
write(l1); | ||
write("\n"); | ||
write(l2); | ||
write("\n"); | ||
write(l3); | ||
write("\n"); | ||
write(l4); | ||
write("\n"); | ||
write(l5[0]); | ||
write("\n"); | ||
write(l5[1]); | ||
write("\n"); | ||
write(l6[0]); | ||
write("\n"); | ||
write(l6[1]); | ||
write("\n"); | ||
write(l7[0]); | ||
write("\n"); | ||
write(l7[1]); | ||
write("\n"); | ||
write(l8[0]); | ||
write("\n"); | ||
write(l8[1]); | ||
write("\n"); | ||
write(l9[0]); | ||
write("\n"); | ||
write(l9[1]); | ||
write("\n"); | ||
write(l10[0]); | ||
write("\n"); | ||
write(l10[1]); | ||
write("\n"); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
1 | ||
2.00000000 | ||
3 | ||
4.00000000 | ||
5 | ||
55 | ||
6.00000000 | ||
66.00000000 | ||
7 | ||
77 | ||
8.00000000 | ||
88.00000000 | ||
9 | ||
99 | ||
10.00000000 | ||
100.00000000 | ||
1 | ||
2.00000000 | ||
3 | ||
4.00000000 | ||
5 | ||
55 | ||
6.00000000 | ||
66.00000000 | ||
7 | ||
77 | ||
8.00000000 | ||
88.00000000 | ||
9 | ||
99 | ||
10.00000000 | ||
100.00000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
int main() { | ||
int a, b; | ||
float c, d; | ||
a = 1; | ||
b = 0; | ||
if (a > b) { | ||
write("correct\n"); | ||
} else { | ||
write("wrong\n"); | ||
} | ||
if (a < b) { | ||
write("wrong\n"); | ||
} else { | ||
write("correct\n"); | ||
} | ||
if (a == b) { | ||
write("wrong\n"); | ||
} else { | ||
write("correct\n"); | ||
} | ||
if (a != b) { | ||
write("correct\n"); | ||
} else { | ||
write("wrong\n"); | ||
} | ||
|
||
c = 1.0; | ||
d = 0.0; | ||
if (c > d) { | ||
write("correct\n"); | ||
} else { | ||
write("wrong\n"); | ||
} | ||
if (c < d) { | ||
write("wrong\n"); | ||
} else { | ||
write("correct\n"); | ||
} | ||
if (c != d) { | ||
write("correct\n"); | ||
} else { | ||
write("wrong\n"); | ||
} | ||
|
||
if (a && b) { | ||
write("wrong\n"); | ||
} | ||
|
||
if (a || b) { | ||
write("correct\n"); | ||
} | ||
|
||
a = 0; | ||
while (a<10) { | ||
write("correct: "); | ||
write(a); | ||
write("\n"); | ||
a = a+1; | ||
} | ||
if (a == 10) { | ||
write("correct\n"); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
correct | ||
correct | ||
correct | ||
correct | ||
correct | ||
correct | ||
correct | ||
correct | ||
correct: 0 | ||
correct: 1 | ||
correct: 2 | ||
correct: 3 | ||
correct: 4 | ||
correct: 5 | ||
correct: 6 | ||
correct: 7 | ||
correct: 8 | ||
correct: 9 | ||
correct |
Oops, something went wrong.