sysy-data/functional_c/asm/57_sort_test3.s

231 lines
3.3 KiB
ArmAsm

.text
.attribute 4, 16
.attribute 5, "rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0"
.file "57_sort_test3.sy"
.globl QuickSort
.p2align 1
.type QuickSort,@function
QuickSort:
addi sp, sp, -32
sd ra, 24(sp)
sd s0, 16(sp)
sd s1, 8(sp)
sd s2, 0(sp)
bge a1, a2, .LBB0_20
mv s2, a2
mv s0, a1
mv s1, a0
j .LBB0_4
.LBB0_2:
mv a2, a1
.LBB0_3:
slli a2, a2, 2
add a2, a2, s1
sw a0, 0(a2)
addiw a2, s0, -1
mv a0, s1
call QuickSort
addiw s0, s0, 1
bge s0, s2, .LBB0_20
.LBB0_4:
sext.w a1, s0
slli a0, a1, 2
add a0, a0, s1
lw a0, 0(a0)
bge a1, s2, .LBB0_2
mv a2, s2
j .LBB0_8
.LBB0_6:
slli a4, a4, 2
add a4, a4, s1
sw s0, 0(a4)
addiw a2, a2, -1
mv s0, a3
.LBB0_7:
sext.w a3, a2
sext.w a4, s0
bge a4, a3, .LBB0_19
.LBB0_8:
sext.w a3, a2
sext.w a4, s0
bge a4, a3, .LBB0_14
slli a2, a3, 2
add a2, a2, s1
.LBB0_10:
lw a5, 0(a2)
blt a5, a0, .LBB0_12
addi a3, a3, -1
addi a2, a2, -4
blt a4, a3, .LBB0_10
j .LBB0_13
.LBB0_12:
slli a2, a4, 2
add a2, a2, s1
sw a5, 0(a2)
addiw s0, s0, 1
.LBB0_13:
mv a2, a3
.LBB0_14:
sext.w a4, a2
sext.w a3, s0
bge a3, a4, .LBB0_7
slli a5, a3, 2
add a5, a5, s1
.LBB0_16:
lw s0, 0(a5)
bge s0, a0, .LBB0_6
addiw s0, a3, 1
addi a3, a3, 1
addi a5, a5, 4
bne a4, s0, .LBB0_16
mv s0, a2
.LBB0_19:
sext.w a2, s0
j .LBB0_3
.LBB0_20:
li a0, 0
ld ra, 24(sp)
ld s0, 16(sp)
ld s1, 8(sp)
ld s2, 0(sp)
addi sp, sp, 32
ret
.Lfunc_end0:
.size QuickSort, .Lfunc_end0-QuickSort
.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 a2, 9
addi s1, sp, 8
li a1, 0
call QuickSort
lw a0, %lo(n)(s2)
blez a0, .LBB1_3
li s0, 0
.LBB1_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, .LBB1_2
.LBB1_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_end1:
.size main, .Lfunc_end1-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