sysy-data/functional_c/asm/60_sort_test6.s

232 lines
3.3 KiB
ArmAsm
Raw Normal View History

2024-06-14 13:34:46 +08:00
.text
.attribute 4, 16
.attribute 5, "rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0"
.file "60_sort_test6.sy"
.globl counting_sort
.p2align 1
.type counting_sort,@function
counting_sort:
addi sp, sp, -48
sd zero, 40(sp)
sd zero, 32(sp)
sd zero, 24(sp)
sd zero, 16(sp)
sd zero, 8(sp)
slli a6, a2, 32
blez a2, .LBB0_4
srli a3, a6, 32
addi a7, sp, 8
mv a5, a0
.LBB0_2:
lw a4, 0(a5)
slli a4, a4, 2
add t0, a7, a4
lw a4, 0(t0)
addiw a4, a4, 1
sw a4, 0(t0)
addi a3, a3, -1
addi a5, a5, 4
bnez a3, .LBB0_2
lw a3, 12(sp)
lw a4, 8(sp)
lw a5, 16(sp)
lw t5, 20(sp)
lw t4, 24(sp)
lw t3, 28(sp)
lw t2, 32(sp)
lw t1, 36(sp)
lw t0, 40(sp)
lw a7, 44(sp)
addw a3, a3, a4
j .LBB0_5
.LBB0_4:
li a7, 0
li t0, 0
li t1, 0
li t2, 0
li t3, 0
li t4, 0
li t5, 0
li a5, 0
li a3, 0
.LBB0_5:
sw a3, 12(sp)
addw a3, a3, a5
sw a3, 16(sp)
addw a3, a3, t5
sw a3, 20(sp)
addw a3, a3, t4
sw a3, 24(sp)
addw a3, a3, t3
sw a3, 28(sp)
addw a3, a3, t2
sw a3, 32(sp)
addw a3, a3, t1
sw a3, 36(sp)
addw a3, a3, t0
sw a3, 40(sp)
addw a3, a3, a7
sw a3, 44(sp)
blez a2, .LBB0_8
srli a3, a6, 32
addi a3, a3, 1
addi a6, sp, 8
li a7, 1
.LBB0_7:
addiw a2, a2, -1
slli a4, a2, 32
srli a4, a4, 30
add a4, a4, a0
lw t0, 0(a4)
slli a5, t0, 2
add a5, a5, a6
lw a4, 0(a5)
addiw a4, a4, -1
sw a4, 0(a5)
slli a4, a4, 2
add a4, a4, a1
addi a3, a3, -1
sw t0, 0(a4)
bltu a7, a3, .LBB0_7
.LBB0_8:
li a0, 0
addi sp, sp, 48
ret
.Lfunc_end0:
.size counting_sort, .Lfunc_end0-counting_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, 8
sw a0, 40(sp)
li a0, 7
sw a0, 36(sp)
li a0, 5
sw a0, 28(sp)
li a0, 6
sw a0, 32(sp)
li s1, 1
sw s1, 12(sp)
sw zero, 8(sp)
li s0, 2
sw s0, 16(sp)
li a0, 9
sw a0, 44(sp)
li a0, 3
sw a0, 20(sp)
li a0, 4
sw a0, 24(sp)
li a0, 0
call putint
li a0, 10
call putch
lw a0, %lo(n)(s2)
blt a0, s0, .LBB1_3
addi s0, sp, 12
.LBB1_2:
lw a0, 0(s0)
call putint
li a0, 10
call putch
lw a0, %lo(n)(s2)
addi s1, s1, 1
addi s0, s0, 4
blt s1, 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