Skip to content

Commit c838edf

Browse files
committed
Fix hello world example, update readme
1 parent a7e135d commit c838edf

File tree

3 files changed

+60
-32
lines changed

3 files changed

+60
-32
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ For running SoomRV on FPGA, have a look at the [SoomRV-Arty Repo](https://github
2020
## Simulating
2121
1. Install the [RV32 Linux Toolchain](https://github.com/riscv-collab/riscv-gnu-toolchain) as well as Verilator (at least version 5.0).
2222
2. Run `make setup` to build submodules.
23-
3. Run `make` to build a binary with Verilator (alternatively, `make trace` will also generate VCD traces)
23+
3. Run `make` to build a binary with Verilator (alternatively, `make trace` will also generate VCD traces).
2424
4. To run bare-metal code, use `./obj_dir/VTop <assembly file>` or `<baremetal elf file>`.
25-
For example, run `./obj_dir/VTop test_programs/dhry_1.s` to run Dhrystone. Optionally add `--perfc` to print out perf counters.
25+
For example, run `./obj_dir/VTop test_programs/dhry_1.s` to run Dhrystone. Optionally add `--perfc` to print out perf counters, or `-x <start_time>` to specify when to enable tracing (`-x0` for tracing from start).
2626
5. To run Linux, use `./obj_dir/VTop --perfc --device-tree=test_programs/linux/device_tree.dtb test_programs/linux/linux_image.elf` (or `make linux` for a full build). Log in as `root`, no password.
2727
Building Linux and booting it in simulation takes at least a few hours!
2828

test_programs/hello_world.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ typedef unsigned int uint32_t;
22

33
static void print (const char* c)
44
{
5-
volatile char* out = (char*) 0xfe000000;
5+
volatile char* out = (char*) 0x10000000;
66
while (*c != 0)
77
*out = *c++;
88
}

test_programs/hello_world.s

Lines changed: 57 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,73 @@
11
.file "hello_world.c"
22
.option nopic
3-
.attribute arch, "rv32i2p0_m2p0_c2p0"
3+
.attribute arch, "rv32i2p1_m2p0_a2p1_c2p0_zba1p0_zbb1p0"
44
.attribute unaligned_access, 0
55
.attribute stack_align, 16
66
.text
7-
.section .rodata.str1.4,"aMS",@progbits,1
7+
.align 1
8+
.type print, @function
9+
print:
10+
addi sp,sp,-48
11+
sw ra,44(sp)
12+
sw s0,40(sp)
13+
addi s0,sp,48
14+
sw a0,-36(s0)
15+
li a5,268435456
16+
sw a5,-20(s0)
17+
j .L2
18+
.L3:
19+
lw a5,-36(s0)
20+
addi a4,a5,1
21+
sw a4,-36(s0)
22+
lbu a4,0(a5)
23+
lw a5,-20(s0)
24+
sb a4,0(a5)
25+
.L2:
26+
lw a5,-36(s0)
27+
lbu a5,0(a5)
28+
bne a5,zero,.L3
29+
nop
30+
nop
31+
lw ra,44(sp)
32+
lw s0,40(sp)
33+
addi sp,sp,48
34+
jr ra
35+
.size print, .-print
36+
.section .rodata
837
.align 2
938
.LC0:
1039
.string "Hello, World!\n"
11-
.section .text.startup,"ax",@progbits
40+
.text
1241
.align 1
1342
.globl main
1443
.type main, @function
1544
main:
16-
addi sp,sp,-16
45+
addi sp,sp,-32
46+
sw ra,28(sp)
47+
sw s0,24(sp)
48+
addi s0,sp,32
1749
lui a5,%hi(.LC0)
18-
sw ra,12(sp)
19-
sw s0,8(sp)
20-
sw s1,4(sp)
21-
li a4,72
22-
addi a5,a5,%lo(.LC0)
23-
li a3,-33554432
24-
.align 4
25-
.L2:
26-
addi a5,a5,1
27-
sb a4,0(a3)
28-
lbu a4,0(a5)
29-
bne a4,zero,.L2
30-
li s0,0
31-
li s1,10
32-
.align 4
33-
.L3:
34-
mv a0,s0
35-
addi s0,s0,1
50+
addi a0,a5,%lo(.LC0)
51+
call print
52+
sw zero,-20(s0)
53+
j .L5
54+
.L6:
55+
lw a5,-20(s0)
56+
mv a0,a5
3657
call printhex
37-
bne s0,s1,.L3
38-
lw ra,12(sp)
39-
lw s0,8(sp)
40-
lw s1,4(sp)
41-
li a0,0
42-
addi sp,sp,16
58+
lw a5,-20(s0)
59+
addi a5,a5,1
60+
sw a5,-20(s0)
61+
.L5:
62+
lw a4,-20(s0)
63+
li a5,9
64+
ble a4,a5,.L6
65+
li a5,0
66+
mv a0,a5
67+
lw ra,28(sp)
68+
lw s0,24(sp)
69+
addi sp,sp,32
4370
jr ra
4471
.size main, .-main
45-
.ident "GCC: (g1ea978e3066) 12.1.0"
72+
.ident "GCC: (g04696df0963) 14.2.0"
73+
.section .note.GNU-stack,"",@progbits

0 commit comments

Comments
 (0)