mirror of
https://github.com/openhwgroup/cvw
synced 2025-01-23 04:54:29 +00:00
Tested assembly language file for the pause example
This commit is contained in:
parent
eba346849c
commit
905c5da7a9
1
.gitignore
vendored
1
.gitignore
vendored
@ -62,6 +62,7 @@ examples/fp/fpcalc/fpcalc
|
||||
examples/C/inline/inline
|
||||
examples/C/sum_mixed/sum_mixed
|
||||
examples/asm/trap/trap
|
||||
examples/asm/etc/pause
|
||||
src/fma/fma16_testgen
|
||||
linux/devicetree/debug/*
|
||||
!linux/devicetree/debug/dump-dts.sh
|
||||
|
11
examples/asm/etc/Makefile
Normal file
11
examples/asm/etc/Makefile
Normal file
@ -0,0 +1,11 @@
|
||||
TARGET = pause
|
||||
|
||||
$(TARGET).objdump: $(TARGET)
|
||||
riscv64-unknown-elf-objdump -D $(TARGET) > $(TARGET).objdump
|
||||
|
||||
pause: pause.S Makefile
|
||||
riscv64-unknown-elf-gcc -o pause -march=rv32ia_zihintpause -mabi=ilp32 -mcmodel=medany \
|
||||
-nostartfiles -T../../link/link.ld pause.S
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET) $(TARGET).objdump
|
25
examples/asm/etc/pause.S
Normal file
25
examples/asm/etc/pause.S
Normal file
@ -0,0 +1,25 @@
|
||||
.section .text.init
|
||||
.globl rvtest_entry_point
|
||||
rvtest_entry_point:
|
||||
|
||||
|
||||
la a0, lock
|
||||
|
||||
spinlock: # address of lock is in a0
|
||||
lr.w t0, (a0) # read the lock
|
||||
bnez t0, retry # spin until free
|
||||
li t1, 1
|
||||
sc.w t0, t1, (a0) # try to write a 1 to take lock
|
||||
bnez t0, retry # spin until successful
|
||||
ret # got the lock!
|
||||
retry: # no lock yet
|
||||
pause # pause hint to reduce spin power
|
||||
j spinlock # try again
|
||||
|
||||
|
||||
self_loop:
|
||||
j self_loop
|
||||
|
||||
.data
|
||||
lock:
|
||||
.word 1
|
Loading…
Reference in New Issue
Block a user