sysy-data/hidden_functional_c/asm/20_sort.s

494 lines
6.5 KiB
ArmAsm

.file "20_sort.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 quick_read
.type quick_read, @function
quick_read:
addi sp,sp,-32
sd s2,0(sp)
sd ra,24(sp)
sd s0,16(sp)
sd s1,8(sp)
call getch@plt
addiw a4,a0,-48
li a5,9
li s2,0
bleu a4,a5,.L2
li s1,45
li s0,9
.L4:
bne a0,s1,.L3
li s2,1
.L3:
call getch@plt
addiw a5,a0,-48
bgtu a5,s0,.L4
.L2:
li a5,0
li s1,9
.L5:
slliw s0,a5,2
addw s0,s0,a5
slliw s0,s0,1
addw s0,s0,a0
call getch@plt
addiw a4,a0,-48
addiw a5,s0,-48
bleu a4,s1,.L5
beq s2,zero,.L6
li a5,48
subw a5,a5,s0
.L6:
ld ra,24(sp)
ld s0,16(sp)
ld s1,8(sp)
ld s2,0(sp)
mv a0,a5
addi sp,sp,32
jr ra
.size quick_read, .-quick_read
.align 1
.globl sortA
.type sortA, @function
sortA:
lla a7,.LANCHOR0
lw a1,0(a7)
addi a0,a0,4
li a6,0
ble a1,zero,.L16
.L23:
addiw a6,a6,1
bge a6,a1,.L16
lw a2,-4(a0)
mv a5,a0
mv a4,a6
.L22:
lw a3,0(a5)
ble a2,a3,.L19
.L27:
sw a3,-4(a0)
sw a2,0(a5)
lw a1,0(a7)
addiw a4,a4,1
addi a5,a5,4
bge a4,a1,.L21
lw a2,-4(a0)
lw a3,0(a5)
bgt a2,a3,.L27
.L19:
addiw a4,a4,1
addi a5,a5,4
blt a4,a1,.L22
.L21:
addi a0,a0,4
bgt a1,a6,.L23
.L16:
ret
.size sortA, .-sortA
.align 1
.globl sortB
.type sortB, @function
sortB:
lw a5,.LANCHOR0
ble a5,zero,.L51
slli a5,a5,2
mv a4,a0
add a2,a5,a0
li a6,-100
lla a1,cnt
.L31:
lw a5,0(a4)
addi a4,a4,4
slli a5,a5,2
add a5,a1,a5
lw a3,0(a5)
addiw a3,a3,1
sw a3,0(a5)
lw a5,-4(a4)
mv a3,a5
bge a5,a6,.L30
mv a3,a6
.L30:
sext.w a6,a3
bne a4,a2,.L31
blt a6,zero,.L51
li t4,-1
lla a7,cnt
addiw a6,a6,1
li a4,0
li a2,0
li t3,5
li t5,1
li t6,2
li t0,3
li t2,4
srli t4,t4,32
.L52:
lw a1,0(a7)
beq a1,zero,.L56
slli a3,a4,2
addi sp,sp,-32
add a3,a0,a3
sd s1,16(sp)
sd s3,0(sp)
srli a5,a3,2
addiw s3,a1,-1
sd s0,24(sp)
sd s2,8(sp)
mv t1,s3
sext.w s1,a1
andi a5,a5,1
bleu s3,t3,.L39
.L58:
beq a5,zero,.L40
addiw s2,a4,1
mv s0,s2
sw a2,0(a3)
mv a1,s3
.L35:
subw s1,s1,a5
add a5,a5,a4
slli a5,a5,2
srliw a4,s1,1
slli s3,a2,32
and a3,a2,t4
add a5,a0,a5
slli a4,a4,3
or a3,a3,s3
add a4,a4,a5
.L36:
sd a3,0(a5)
addi a5,a5,8
bne a5,a4,.L36
andi a5,s1,1
beq a5,zero,.L37
andi s1,s1,-2
addw a4,s1,s2
subw a1,a1,s1
.L34:
slli a4,a4,2
add a4,a0,a4
sw a2,0(a4)
beq a1,t5,.L37
sw a2,4(a4)
beq a1,t6,.L37
sw a2,8(a4)
beq a1,t0,.L37
sw a2,12(a4)
beq a1,t2,.L37
sw a2,16(a4)
beq a1,t3,.L37
sw a2,20(a4)
.L37:
addw a4,s0,t1
.L33:
addiw a2,a2,1
addi a7,a7,4
beq a2,a6,.L57
lw a1,0(a7)
beq a1,zero,.L33
slli a3,a4,2
add a3,a0,a3
addiw s3,a1,-1
srli a5,a3,2
mv t1,s3
sext.w s1,a1
andi a5,a5,1
bgtu s3,t3,.L58
.L39:
addiw s0,a4,1
j .L34
.L40:
mv s2,a4
addiw s0,a4,1
j .L35
.L57:
ld s0,24(sp)
ld s1,16(sp)
ld s2,8(sp)
ld s3,0(sp)
addi sp,sp,32
jr ra
.L56:
addiw a2,a2,1
addi a7,a7,4
bne a2,a6,.L52
ret
.L51:
ret
.size sortB, .-sortB
.align 1
.globl sortC
.type sortC, @function
sortC:
lla t6,.LANCHOR0
lw t1,0(t6)
mv t4,a0
li t3,0
ble t1,zero,.L59
.L64:
mv a6,t3
addiw t3,t3,1
lw t5,0(t4)
bge t3,t1,.L66
slli a5,t3,2
add a5,a0,a5
mv a2,t5
mv a4,t3
j .L63
.L71:
addiw a4,a4,1
add a1,a0,a7
addi a5,a5,4
beq a4,t1,.L61
.L63:
lw a3,0(a5)
slli a7,a6,2
mv a1,a5
bge a3,a2,.L71
mv a6,a4
addiw a4,a4,1
mv a2,a3
addi a5,a5,4
bne a4,t1,.L63
.L61:
sw a2,0(t4)
sw t5,0(a1)
lw t1,0(t6)
addi t4,t4,4
bgt t1,t3,.L64
.L59:
ret
.L66:
mv a2,t5
sw a2,0(t4)
mv a1,t4
sw t5,0(a1)
lw t1,0(t6)
addi t4,t4,4
bgt t1,t3,.L64
j .L59
.size sortC, .-sortC
.section .text.startup,"ax",@progbits
.align 1
.globl main
.type main, @function
main:
addi sp,sp,-96
sd s6,32(sp)
sd ra,88(sp)
sd s0,80(sp)
sd s1,72(sp)
sd s2,64(sp)
sd s3,56(sp)
sd s4,48(sp)
sd s5,40(sp)
sd s7,24(sp)
sd s8,16(sp)
sd s9,8(sp)
lla s6,.LANCHOR0
call quick_read
sw a0,0(s6)
beq a0,zero,.L73
lla s5,a
lla s4,b
lla s3,c
li s2,0
li s0,9
li s1,45
li s7,48
.L80:
call getch@plt
addiw a5,a0,-48
li s8,0
bleu a5,s0,.L74
.L76:
bne a0,s1,.L75
li s8,1
.L75:
call getch@plt
addiw a5,a0,-48
bgtu a5,s0,.L76
.L74:
li a5,0
.L77:
slliw s9,a5,2
addw s9,s9,a5
slliw s9,s9,1
addw s9,s9,a0
call getch@plt
addiw a5,s9,-48
addiw a3,a0,-48
mv a4,a5
bleu a3,s0,.L77
lw a5,0(s6)
beq s8,zero,.L78
subw s9,s7,s9
sw s9,0(s5)
sw s9,0(s4)
sw s9,0(s3)
.L100:
addiw s2,s2,1
addi s5,s5,4
addi s4,s4,4
addi s3,s3,4
bne a5,s2,.L80
.L73:
lla a0,a
call sortA
lla a0,b
call sortB
lla a0,c
call sortC
lw a5,0(s6)
beq a5,zero,.L81
lla a2,b
lla a0,c
slli a5,a5,2
lla a6,a
add t1,a5,a2
mv a1,a0
mv a4,a2
.L82:
lw a7,0(a6)
lw a3,0(a4)
lw a5,0(a1)
addi a4,a4,4
subw a3,a3,a7
subw a5,a5,a3
subw a5,a5,a7
sw a5,0(a1)
sw a3,-4(a4)
addi a6,a6,4
addi a1,a1,4
bne a4,t1,.L82
lw a5,0(a2)
addi a2,a2,4
bne a5,zero,.L87
.L101:
lw a5,0(a0)
addi a0,a0,4
bne a5,zero,.L88
beq a2,t1,.L81
lw a5,0(a2)
addi a2,a2,4
beq a5,zero,.L101
.L87:
li a0,1
.L84:
ld ra,88(sp)
ld s0,80(sp)
ld s1,72(sp)
ld s2,64(sp)
ld s3,56(sp)
ld s4,48(sp)
ld s5,40(sp)
ld s6,32(sp)
ld s7,24(sp)
ld s8,16(sp)
ld s9,8(sp)
addi sp,sp,96
jr ra
.L78:
sw a4,0(s5)
sw a4,0(s4)
sw a4,0(s3)
j .L100
.L81:
li a0,-123
j .L84
.L88:
li a0,2
j .L84
.size main, .-main
.globl c
.globl b
.globl a
.globl x
.globl cnt
.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 c, @object
.size c, 400020
c:
.zero 400020
.zero 4
.type b, @object
.size b, 400020
b:
.zero 400020
.zero 4
.type a, @object
.size a, 400020
a:
.zero 400020
.zero 4
.type x, @object
.size x, 400020
x:
.zero 400020
.zero 4
.type cnt, @object
.size cnt, 1600080
cnt:
.zero 1600080
.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