ea95459
514 lines (406 sloc)
16.7 KB
-M
x0 x31
PC x0
x1 x31
a0 a7 sp
t0 t6
s0 s11
C.UNIMP 0000
UNIMP C0001073
.option norvc
UNIMP
UNIMP
0000 0000
UNIMP
CSRRW x0, cycle, x0
cycle
UNIMP
loop:
j loop
1:
j 1b
.section .text
.globl _start
_start:
lui a0,
addi a0, a0, %lo(msg)
jal ra, puts
2: j 2b
.section .rodata
msg:
.string “Hello World\n”
# load msg(hi)
# load msg(lo)
%hi(msg)
0000000000000000 <_start>:
0: 000005b7 lui a1,0x0
0: R_RISCV_HI20 msg
4: 00858593 addi a1,a1,8 # 8 <.L21>
4: R_RISCV_LO12_I msg
.section .text
.globl _start
_start:
1: auipc a0, %pcrel_hi(msg) # load msg(hi)
addi a0, a0, %pcrel_lo(1b) # load msg(lo)
jal ra, puts
2: j 2b
.section .rodata
msg:
.string “Hello World\n”
0000000000000000 <_start>:
0: 00000597
4: 00858593
auipc a1,0x0
0: R_RISCV_PCREL_HI20 msg
addi a1,a1,8 # 8 <.L21>
4: R_RISCV_PCREL_LO12_I .L11
.section .text
.globl _start
_start:
1: auipc a0, %got_pcrel_hi(msg) # load msg(hi)
ld a0, %pcrel_lo(1b)(a0) # load msg(lo)
jal ra, puts
2: j 2b
.section .rodata
msg:
.string “Hello World\n”
0000000000000000 <_start>:
0: 00000517
4: 00053503
.section .text
.globl _start
_start:
auipc a0,0x0
0: R_RISCV_GOT_HI20 msg
ld a0,0(a0) # 0 <_start>
4: R_RISCV_PCREL_LO12_I .L11
li
.equ CONSTANT, 0xcafebabe
li a0, CONSTANT
0000000000000000 <_start>:
0: 00032537
4: bfb50513
8: 00e51513
c: abe50513
.section .text
.globl _start
_start:
la a0, msg
.section .rodata
msg:
lui a0,0x32
addi a0,a0,-1029
slli a0,a0,0xe
addi a0,a0,-1346
la
.string “Hello World\n”
0000000000000000 <_start>:
0: 00000517 auipc a0,0x0
0: R_RISCV_PCREL_HI20 msg
4: 00850513 addi a0,a0,8 # 8 <_start+0x8>
4: R_RISCV_PCREL_LO12_I .L11
0000000000000000 <_start>:
0: 00000517 auipc a0,0x0
0: R_RISCV_GOT_HI20 msg
4: 00053503 ld a0,0(a0) # 0 <_start>
4: R_RISCV_PCREL_LO12_I .L0
.equ UART_BASE, 0x40003000
lui a0, %hi(UART_BASE)
addi a0, a0, %lo(UART_BASE)
.equ UART_BASE, 0x40003000
.equ REG_RBR, 0
.equ REG_TBR, 0
.equ REG_IIR, 2
.equ IIR_TX_RDY, 2
.equ IIR_RX_RDY, 4
.section .text
.globl _start
_start:
1: auipc a0, %pcrel_hi(msg)
rne
rtz
rdn
rup
rmm
dyn
frm fcsr
li
# load msg(hi)
addi a0, a0, %pcrel_lo(1b) # load msg(lo)
2: jal ra, puts
3: j3b
puts:
li a2, UART_BASE
1: lbu a1, (a0)
beqz a1, 3f
2: lbu a3, REG_IIR(a2)
andi a3, a3, IIR_TX_RDY
beqz a3, 2b
sb a1, REG_TBR(a2)
addi a0, a0, 1
j 1b
3: ret
.section .rodata
msg:
.string “Hello World\n”
fcvt.w.s dyn
fcvt.w.s a0, fa0, rtz
.equ RTC_BASE, 0x40000000
.equ TIMER_BASE, 0x40004000
# setup machine trap vector
1: auipc addi
csrrw
t0, %pcrel_hi(mtvec)
t0, t0, %pcrel_lo(1b)
zero, mtvec, t0
# load mtvec(hi)
# load mtvec(lo)
# set mstatus.MIE=1 (enable M mode interrupt)
li t0, 8
csrrs zero, mstatus, t0
# set mie.MTIE=1 (enable M mode timer interrupts)
li t0, 128
csrrs zero, mie, t0
# read from mtime
li a0, RTC_BASE
ld a1, 0(a0)
# write to mtimecmp
li a0, TIMER_BASE
li t0, 1000000000
add a1, a1, t0
sd a1, 0(a0)
# loop loop:
wfi
j loop
# break on interrupt
mtvec:
pass:
fail:
csrrc t0, mcause, zero
bgez t0, fail
slli t0, t0, 1
srli t0, t0, 1
li t1, 7
bne t0, t1, fail
j pass
la a0, pass_msg
jal puts
j shutdown
la a0, fail_msg
jal puts
j shutdown
# interrupt causes are less than zero
# shift off high bit
# check this is an m_timer interrupt
.section .rodata
pass_msg:
.string “PASS\n”
fail_msg:
.string “FAIL\n”