268 lines
3.7 KiB
ArmAsm
268 lines
3.7 KiB
ArmAsm
.file "median0.sy"
|
|
.option pic
|
|
.attribute arch, "rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0"
|
|
.attribute unaligned_access, 0
|
|
.attribute stack_align, 16
|
|
.text
|
|
.align 1
|
|
.globl meanless_calculation
|
|
.type meanless_calculation, @function
|
|
meanless_calculation:
|
|
mv a3,a0
|
|
li a0,0
|
|
ble a3,zero,.L4
|
|
ble a1,zero,.L2
|
|
li a5,0
|
|
j .L3
|
|
.L9:
|
|
beq a1,a5,.L8
|
|
.L3:
|
|
addiw a5,a5,1
|
|
addw a0,a3,a0
|
|
addw a0,a0,a5
|
|
bne a3,a5,.L9
|
|
.L2:
|
|
ret
|
|
.L8:
|
|
ret
|
|
.L4:
|
|
ret
|
|
.size meanless_calculation, .-meanless_calculation
|
|
.align 1
|
|
.globl swap
|
|
.type swap, @function
|
|
swap:
|
|
slli a5,a2,2
|
|
add a5,a0,a5
|
|
slli a4,a1,2
|
|
add a0,a0,a4
|
|
lw a3,0(a5)
|
|
lw a4,0(a0)
|
|
sw a3,0(a0)
|
|
sw a4,0(a5)
|
|
li a0,0
|
|
ble a1,zero,.L13
|
|
ble a2,zero,.L11
|
|
li a5,0
|
|
j .L12
|
|
.L17:
|
|
beq a2,a5,.L16
|
|
.L12:
|
|
addiw a5,a5,1
|
|
addw a0,a1,a0
|
|
addw a0,a5,a0
|
|
bne a1,a5,.L17
|
|
.L11:
|
|
ret
|
|
.L16:
|
|
ret
|
|
.L13:
|
|
ret
|
|
.size swap, .-swap
|
|
.align 1
|
|
.globl median
|
|
.type median, @function
|
|
median:
|
|
addi sp,sp,-16
|
|
sd s0,8(sp)
|
|
sd s1,0(sp)
|
|
mv t0,a1
|
|
mv t4,a0
|
|
mv s0,a3
|
|
slli s1,a1,2
|
|
addiw t2,a2,1
|
|
.L19:
|
|
add t6,t4,s1
|
|
lw a6,0(t6)
|
|
sext.w t5,t2
|
|
mv t1,t0
|
|
li a0,0
|
|
.L20:
|
|
blt t1,t5,.L24
|
|
slli a2,t1,2
|
|
add a2,t4,a2
|
|
mv t3,t5
|
|
mv a1,t1
|
|
.L25:
|
|
beq a1,t3,.L28
|
|
.L42:
|
|
slli a5,t3,2
|
|
add a5,t4,a5
|
|
lw a3,0(a5)
|
|
lw a4,0(a2)
|
|
sw a3,0(a2)
|
|
sw a4,0(a5)
|
|
blt t1,t5,.L39
|
|
slli a1,a1,2
|
|
add t4,t4,a1
|
|
.L23:
|
|
lw a3,0(a5)
|
|
lw a4,0(t4)
|
|
sw a3,0(t4)
|
|
sw a4,0(a5)
|
|
j .L23
|
|
.L24:
|
|
addiw t3,t5,-1
|
|
slli a5,t3,2
|
|
add a5,t4,a5
|
|
lw a5,0(a5)
|
|
blt a5,a6,.L21
|
|
addiw a0,a0,1
|
|
mv t5,t3
|
|
j .L20
|
|
.L21:
|
|
bge t1,t3,.L40
|
|
addw a3,a0,t1
|
|
addi a5,t1,1
|
|
addiw a7,a3,1
|
|
slli a5,a5,2
|
|
add a5,t4,a5
|
|
subw a3,a7,t5
|
|
j .L26
|
|
.L41:
|
|
addiw a0,a0,-1
|
|
addi a5,a5,4
|
|
beq a0,a3,.L25
|
|
.L26:
|
|
lw a4,0(a5)
|
|
subw a1,a7,a0
|
|
mv a2,a5
|
|
blt a4,a6,.L41
|
|
bne a1,t3,.L42
|
|
.L28:
|
|
sw a6,0(t6)
|
|
lw a5,0(a2)
|
|
sw a5,0(t6)
|
|
sw a6,0(a2)
|
|
blt s0,a1,.L33
|
|
ble s0,a1,.L34
|
|
addiw t0,a1,1
|
|
slli s1,t0,2
|
|
j .L19
|
|
.L33:
|
|
addiw t2,a1,1
|
|
j .L19
|
|
.L34:
|
|
ld s0,8(sp)
|
|
ld s1,0(sp)
|
|
addi sp,sp,16
|
|
jr ra
|
|
.L39:
|
|
mv t1,a1
|
|
mv t5,t3
|
|
j .L20
|
|
.L40:
|
|
slli a2,t1,2
|
|
add a2,t4,a2
|
|
mv a1,t1
|
|
j .L25
|
|
.size median, .-median
|
|
.section .text.startup,"ax",@progbits
|
|
.align 1
|
|
.globl main
|
|
.type main, @function
|
|
main:
|
|
addi sp,sp,-16
|
|
lla a0,a
|
|
sd ra,8(sp)
|
|
sd s0,0(sp)
|
|
call getarray@plt
|
|
mv a5,a0
|
|
lla s0,.LANCHOR0
|
|
li a0,61
|
|
sw a5,0(s0)
|
|
call _sysy_starttime@plt
|
|
lw a2,0(s0)
|
|
li a1,0
|
|
lla a0,a
|
|
srliw a3,a2,31
|
|
addw a3,a3,a2
|
|
sraiw a3,a3,1
|
|
addiw a2,a2,-1
|
|
call median
|
|
li a0,63
|
|
call _sysy_stoptime@plt
|
|
lw a0,0(s0)
|
|
lla a1,a
|
|
call putarray@plt
|
|
lw a4,0(s0)
|
|
ld ra,8(sp)
|
|
ld s0,0(sp)
|
|
srliw a5,a4,31
|
|
addw a5,a5,a4
|
|
sraiw a5,a5,1
|
|
slli a5,a5,2
|
|
lla a4,a
|
|
add a5,a4,a5
|
|
lw a5,0(a5)
|
|
addi sp,sp,16
|
|
sraiw a0,a5,31
|
|
srliw a0,a0,24
|
|
addw a5,a0,a5
|
|
andi a5,a5,255
|
|
subw a0,a5,a0
|
|
jr ra
|
|
.size main, .-main
|
|
.globl a
|
|
.globl n
|
|
.globl _sysy_idx
|
|
.globl _sysy_us
|
|
.globl _sysy_s
|
|
.globl _sysy_m
|
|
.globl _sysy_h
|
|
.globl _sysy_l2
|
|
.globl _sysy_l1
|
|
.globl _sysy_end
|
|
.globl _sysy_start
|
|
.bss
|
|
.align 3
|
|
.set .LANCHOR0,. + 0
|
|
.type n, @object
|
|
.size n, 4
|
|
n:
|
|
.zero 4
|
|
.zero 4
|
|
.type a, @object
|
|
.size a, 40000000
|
|
a:
|
|
.zero 40000000
|
|
.type _sysy_idx, @object
|
|
.size _sysy_idx, 4
|
|
_sysy_idx:
|
|
.zero 4
|
|
.zero 4
|
|
.type _sysy_us, @object
|
|
.size _sysy_us, 4096
|
|
_sysy_us:
|
|
.zero 4096
|
|
.type _sysy_s, @object
|
|
.size _sysy_s, 4096
|
|
_sysy_s:
|
|
.zero 4096
|
|
.type _sysy_m, @object
|
|
.size _sysy_m, 4096
|
|
_sysy_m:
|
|
.zero 4096
|
|
.type _sysy_h, @object
|
|
.size _sysy_h, 4096
|
|
_sysy_h:
|
|
.zero 4096
|
|
.type _sysy_l2, @object
|
|
.size _sysy_l2, 4096
|
|
_sysy_l2:
|
|
.zero 4096
|
|
.type _sysy_l1, @object
|
|
.size _sysy_l1, 4096
|
|
_sysy_l1:
|
|
.zero 4096
|
|
.type _sysy_end, @object
|
|
.size _sysy_end, 16
|
|
_sysy_end:
|
|
.zero 16
|
|
.type _sysy_start, @object
|
|
.size _sysy_start, 16
|
|
_sysy_start:
|
|
.zero 16
|
|
.ident "GCC: (Debian 12.2.0-13) 12.2.0"
|
|
.section .note.GNU-stack,"",@progbits
|