sysy-data/functional_c/asm/59_sort_test5.s

298 lines
4.2 KiB
ArmAsm

.text
.attribute 4, 16
.attribute 5, "rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0"
.file "59_sort_test5.sy"
.globl swap
.p2align 1
.type swap,@function
swap:
slli a1, a1, 2
add a1, a1, a0
slli a2, a2, 2
add a0, a0, a2
lw a2, 0(a0)
lw a3, 0(a1)
sw a2, 0(a1)
sw a3, 0(a0)
li a0, 0
ret
.Lfunc_end0:
.size swap, .Lfunc_end0-swap
.globl heap_ajust
.p2align 1
.type heap_ajust,@function
heap_ajust:
slliw a5, a1, 1
ori a3, a5, 1
blt a2, a3, .LBB1_6
.LBB1_1:
bge a3, a2, .LBB1_3
slli a4, a3, 2
add a4, a4, a0
lw a4, 0(a4)
addiw a6, a5, 2
slli a5, a6, 2
add a5, a5, a0
lw a5, 0(a5)
blt a4, a5, .LBB1_4
.LBB1_3:
mv a6, a3
.LBB1_4:
sext.w a1, a1
slli a1, a1, 2
add a3, a0, a1
lw a1, 0(a3)
slli a4, a6, 2
add a4, a4, a0
lw a5, 0(a4)
blt a5, a1, .LBB1_6
sw a5, 0(a3)
slliw a5, a6, 1
ori a3, a5, 1
sw a1, 0(a4)
mv a1, a6
bge a2, a3, .LBB1_1
.LBB1_6:
li a0, 0
ret
.Lfunc_end1:
.size heap_ajust, .Lfunc_end1-heap_ajust
.globl heap_sort
.p2align 1
.type heap_sort,@function
heap_sort:
li a2, 2
blt a1, a2, .LBB2_20
srliw t0, a1, 1
addiw t1, a1, -1
li a6, 1
j .LBB2_3
.LBB2_2:
bge a6, a7, .LBB2_10
.LBB2_3:
mv a7, t0
addiw t0, t0, -1
slliw a2, t0, 1
ori a4, a2, 1
bge a4, a1, .LBB2_2
mv a5, t0
.LBB2_5:
bge a4, t1, .LBB2_7
slli a3, a4, 2
add a3, a3, a0
lw a3, 0(a3)
addiw t2, a2, 2
slli a2, t2, 2
add a2, a2, a0
lw a2, 0(a2)
blt a3, a2, .LBB2_8
.LBB2_7:
mv t2, a4
.LBB2_8:
slli a2, a5, 2
add a2, a2, a0
lw a5, 0(a2)
slli a3, t2, 2
add a3, a3, a0
lw a4, 0(a3)
blt a4, a5, .LBB2_2
sw a4, 0(a2)
slliw a2, t2, 1
ori a4, a2, 1
sw a5, 0(a3)
mv a5, t2
blt a4, a1, .LBB2_5
j .LBB2_2
.LBB2_10:
li a2, 2
blt a1, a2, .LBB2_20
slli a1, t1, 32
srli a1, a1, 32
li a6, 1
j .LBB2_13
.LBB2_12:
addi a1, a7, -1
bge a6, a7, .LBB2_20
.LBB2_13:
mv a7, a1
slli a1, a1, 2
add a1, a1, a0
lw a2, 0(a1)
lw a3, 0(a0)
sw a2, 0(a0)
addiw t1, t1, -1
sw a3, 0(a1)
beqz t1, .LBB2_12
li a1, 0
li a4, 0
li a2, 1
.LBB2_15:
bge a2, t1, .LBB2_17
slli a3, a2, 2
add a3, a3, a0
lw a3, 0(a3)
addiw a5, a1, 2
slli a1, a5, 2
add a1, a1, a0
lw a1, 0(a1)
blt a3, a1, .LBB2_18
.LBB2_17:
mv a5, a2
.LBB2_18:
slli a1, a4, 2
add a1, a1, a0
lw a4, 0(a1)
slli a2, a5, 2
add a3, a0, a2
lw a2, 0(a3)
blt a2, a4, .LBB2_12
sw a2, 0(a1)
slliw a1, a5, 1
ori a2, a1, 1
sw a4, 0(a3)
mv a4, a5
blt a2, a7, .LBB2_15
j .LBB2_12
.LBB2_20:
li a0, 0
ret
.Lfunc_end2:
.size heap_sort, .Lfunc_end2-heap_sort
.globl main
.p2align 1
.type main,@function
main:
addi sp, sp, -80
sd ra, 72(sp)
sd s0, 64(sp)
sd s1, 56(sp)
sd s2, 48(sp)
lui s2, %hi(n)
li a0, 10
sw a0, %lo(n)(s2)
li a0, 4
sw a0, 8(sp)
li a0, 3
sw a0, 12(sp)
li a0, 9
sw a0, 16(sp)
li a0, 2
sw a0, 20(sp)
sw zero, 24(sp)
li a0, 1
sw a0, 28(sp)
li a0, 6
sw a0, 32(sp)
li a0, 5
sw a0, 36(sp)
li a0, 7
sw a0, 40(sp)
li a0, 8
sw a0, 44(sp)
addi a0, sp, 8
li a1, 10
addi s1, sp, 8
call heap_sort
lw a0, %lo(n)(s2)
blez a0, .LBB3_3
li s0, 0
.LBB3_2:
lw a0, 0(s1)
call putint
li a0, 10
call putch
lw a0, %lo(n)(s2)
addi s0, s0, 1
addi s1, s1, 4
blt s0, a0, .LBB3_2
.LBB3_3:
li a0, 0
ld ra, 72(sp)
ld s0, 64(sp)
ld s1, 56(sp)
ld s2, 48(sp)
addi sp, sp, 80
ret
.Lfunc_end3:
.size main, .Lfunc_end3-main
.type n,@object
.section .sbss,"aw",@nobits
.globl n
.p2align 2
n:
.word 0
.size n, 4
.type _sysy_start,@object
.bss
.globl _sysy_start
.p2align 3
_sysy_start:
.zero 16
.size _sysy_start, 16
.type _sysy_end,@object
.globl _sysy_end
.p2align 3
_sysy_end:
.zero 16
.size _sysy_end, 16
.type _sysy_l1,@object
.globl _sysy_l1
.p2align 2
_sysy_l1:
.zero 4096
.size _sysy_l1, 4096
.type _sysy_l2,@object
.globl _sysy_l2
.p2align 2
_sysy_l2:
.zero 4096
.size _sysy_l2, 4096
.type _sysy_h,@object
.globl _sysy_h
.p2align 2
_sysy_h:
.zero 4096
.size _sysy_h, 4096
.type _sysy_m,@object
.globl _sysy_m
.p2align 2
_sysy_m:
.zero 4096
.size _sysy_m, 4096
.type _sysy_s,@object
.globl _sysy_s
.p2align 2
_sysy_s:
.zero 4096
.size _sysy_s, 4096
.type _sysy_us,@object
.globl _sysy_us
.p2align 2
_sysy_us:
.zero 4096
.size _sysy_us, 4096
.type _sysy_idx,@object
.section .sbss,"aw",@nobits
.globl _sysy_idx
.p2align 2
_sysy_idx:
.word 0
.size _sysy_idx, 4
.ident "Debian clang version 14.0.6"
.section ".note.GNU-stack","",@progbits
.addrsig