Make code compatible with LLVM
This commit is contained in:
parent
e52725d564
commit
99aab87cbd
4 changed files with 14 additions and 7 deletions
|
@ -19,6 +19,10 @@ Notes
|
|||
|
||||
readelf -l calc.elf
|
||||
|
||||
### Build with LLVM
|
||||
|
||||
make AS=clang ASFLAGS="-g -mabi=ilp32e --target=riscv32-unknown-elf -nostdlib -c"
|
||||
|
||||
Resources
|
||||
---------
|
||||
|
||||
|
|
4
debug.s
4
debug.s
|
@ -57,7 +57,7 @@ regdump_loop:
|
|||
lw ra, 0(sp) # restore contents of ra
|
||||
addi sp, sp, 4 # deallocate stack space
|
||||
# append ': '
|
||||
li t0, ':
|
||||
li t0, ':'
|
||||
sb t0, 0(a0)
|
||||
li t0, 0x20
|
||||
sb t0, 1(a0)
|
||||
|
@ -73,7 +73,7 @@ regdump_loop:
|
|||
lw ra, 0(sp) # restore contents of ra
|
||||
lw a1, 4(sp) # restore contents of a1 (buffer)
|
||||
addi sp, sp, 8 # deallocate stack space
|
||||
li t0, '\n # append newline
|
||||
li t0, '\n' # append newline
|
||||
sb t0, 8(a1)
|
||||
|
||||
# print the register name and value
|
||||
|
|
|
@ -23,8 +23,11 @@ inputs:
|
|||
.word 1 # 1
|
||||
.word 0x80000000 # 0.5
|
||||
.word 2 # 2
|
||||
|
||||
.set inputs_end, .-inputs
|
||||
inputs_end:
|
||||
# llvm doesn't like this: error: expected relocatable expression
|
||||
#.set inputs_end, .-inputs
|
||||
# turns out it was right. That was calculating a length, which was
|
||||
# incorrect for how it was used for looping.
|
||||
|
||||
.section .bss
|
||||
|
||||
|
@ -33,7 +36,7 @@ buf: .skip 9
|
|||
.text
|
||||
|
||||
_start:
|
||||
li a0, '\n
|
||||
li a0, '\n'
|
||||
la a1, buf
|
||||
sb a0, 8(a1) # append newline to buf
|
||||
|
||||
|
@ -66,7 +69,7 @@ loop:
|
|||
li t0, SYSWRITE # "write" syscall
|
||||
li a0, 1 # 1 = standard output (stdout)
|
||||
la a1, buf # load address of output string
|
||||
li a2, '.
|
||||
li a2, '.'
|
||||
sb a2, 0(a1)
|
||||
li a2, 1 # length of output string
|
||||
ecall # invoke syscall to print the string
|
||||
|
|
|
@ -15,7 +15,7 @@ buf: .skip 9
|
|||
|
||||
.text
|
||||
_start:
|
||||
li a0, '\n
|
||||
li a0, '\n'
|
||||
la a1, buf
|
||||
sb a0, 8(a1) # append newline to buf
|
||||
li a0, 0xCAFEFEED
|
||||
|
|
Loading…
Reference in a new issue