Fix hello.s so that it only prints 5 times and exits

This commit is contained in:
Wesley Moore 2025-02-09 11:32:46 +10:00
parent 56fbb245cd
commit ba9abb1cc0
No known key found for this signature in database
2 changed files with 6 additions and 4 deletions

View file

@ -20,6 +20,8 @@ Resources
### Syscalls on RV32E
[Syscalls supported by rv32emu](https://github.com/sysprog21/rv32emu/blob/master/docs/syscall.md).
Consensus seems to be pass the syscall number in `t0`:
* https://github.com/riscvarchive/riscv-qemu/pull/61

View file

@ -14,8 +14,8 @@ str: .ascii "Hello World!\n"
.text
_start:
li t0, 0
li t1, 5
li t1, 0
li t2, 5
# dummy test for jal instruction
.L1:
@ -24,14 +24,14 @@ _start:
nop
loop:
beq t0, t1, end
beq t1, t2, end
li t0, SYSWRITE # "write" syscall
li a0, 1 # 1 = standard output (stdout)
la a1, str # load address of hello string
li a2, str_size # length of hello string
ecall # invoke syscall to print the string
addi t0, t0, 1
addi t1, t1, 1
j loop
end: