237 lines
3.5 KiB
ArmAsm
237 lines
3.5 KiB
ArmAsm
.text
|
|
.attribute 4, 16
|
|
.attribute 5, "rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0"
|
|
.file "61_sort_test7.sy"
|
|
.globl merge_sort
|
|
.p2align 1
|
|
.type merge_sort,@function
|
|
merge_sort:
|
|
addi sp, sp, -48
|
|
sd ra, 40(sp)
|
|
sd s0, 32(sp)
|
|
sd s1, 24(sp)
|
|
sd s2, 16(sp)
|
|
sd s3, 8(sp)
|
|
sd s4, 0(sp)
|
|
mv s2, a0
|
|
addiw a0, a0, 1
|
|
bge a0, a1, .LBB0_15
|
|
mv s3, a1
|
|
addw a0, a1, s2
|
|
srliw a1, a0, 31
|
|
addw a0, a0, a1
|
|
sraiw s4, a0, 1
|
|
mv a0, s2
|
|
mv a1, s4
|
|
call merge_sort
|
|
mv a0, s4
|
|
mv a1, s3
|
|
call merge_sort
|
|
slt a0, s2, s4
|
|
xori a0, a0, 1
|
|
slt a1, s4, s3
|
|
xori a1, a1, 1
|
|
or a0, a0, a1
|
|
slli a6, s2, 2
|
|
mv a3, s2
|
|
mv a1, s4
|
|
mv a2, s2
|
|
bnez a0, .LBB0_6
|
|
lui a0, %hi(buf)
|
|
addi a4, a0, %lo(buf)
|
|
add a0, a4, a6
|
|
addi a5, a0, 400
|
|
mv a2, s2
|
|
mv a1, s4
|
|
mv a3, s2
|
|
j .LBB0_4
|
|
.LBB0_3:
|
|
slt a0, a0, s1
|
|
xori s1, a0, 1
|
|
addw a3, a3, a0
|
|
addw a1, a1, s1
|
|
sw s0, 0(a5)
|
|
addi a2, a2, 1
|
|
slt a0, a3, s4
|
|
slt s1, a1, s3
|
|
and a0, a0, s1
|
|
addi a5, a5, 4
|
|
beqz a0, .LBB0_6
|
|
.LBB0_4:
|
|
sext.w a0, a3
|
|
slli a0, a0, 2
|
|
add a0, a0, a4
|
|
lw a0, 0(a0)
|
|
slli s1, a1, 2
|
|
add s1, s1, a4
|
|
lw s1, 0(s1)
|
|
mv s0, a0
|
|
blt a0, s1, .LBB0_3
|
|
mv s0, s1
|
|
j .LBB0_3
|
|
.LBB0_6:
|
|
bge a3, s4, .LBB0_9
|
|
sext.w a2, a2
|
|
slli a0, a3, 2
|
|
lui a4, %hi(buf)
|
|
addi a5, a4, %lo(buf)
|
|
add a4, a0, a5
|
|
sub a3, s4, a3
|
|
slli a0, a2, 2
|
|
add a0, a0, a5
|
|
addi a5, a0, 400
|
|
.LBB0_8:
|
|
lw a0, 0(a4)
|
|
sw a0, 0(a5)
|
|
addi a2, a2, 1
|
|
addi a4, a4, 4
|
|
addi a3, a3, -1
|
|
addi a5, a5, 4
|
|
bnez a3, .LBB0_8
|
|
.LBB0_9:
|
|
bge a1, s3, .LBB0_12
|
|
sext.w a0, a2
|
|
slli a2, a1, 2
|
|
lui a3, %hi(buf)
|
|
addi a3, a3, %lo(buf)
|
|
add a2, a2, a3
|
|
sub a1, s3, a1
|
|
slli a0, a0, 2
|
|
add a0, a0, a3
|
|
addi a3, a0, 400
|
|
.LBB0_11:
|
|
lw a0, 0(a2)
|
|
sw a0, 0(a3)
|
|
addi a2, a2, 4
|
|
addi a1, a1, -1
|
|
addi a3, a3, 4
|
|
bnez a1, .LBB0_11
|
|
.LBB0_12:
|
|
bge s2, s3, .LBB0_15
|
|
lui a0, %hi(buf)
|
|
addi a0, a0, %lo(buf)
|
|
add a0, a0, a6
|
|
sub a1, s3, s2
|
|
.LBB0_14:
|
|
lw a2, 400(a0)
|
|
sw a2, 0(a0)
|
|
addi a1, a1, -1
|
|
addi a0, a0, 4
|
|
bnez a1, .LBB0_14
|
|
.LBB0_15:
|
|
ld ra, 40(sp)
|
|
ld s0, 32(sp)
|
|
ld s1, 24(sp)
|
|
ld s2, 16(sp)
|
|
ld s3, 8(sp)
|
|
ld s4, 0(sp)
|
|
addi sp, sp, 48
|
|
ret
|
|
.Lfunc_end0:
|
|
.size merge_sort, .Lfunc_end0-merge_sort
|
|
|
|
.globl main
|
|
.p2align 1
|
|
.type main,@function
|
|
main:
|
|
addi sp, sp, -32
|
|
sd ra, 24(sp)
|
|
sd s0, 16(sp)
|
|
sd s1, 8(sp)
|
|
lui a0, %hi(buf)
|
|
addi s0, a0, %lo(buf)
|
|
mv a0, s0
|
|
call getarray
|
|
mv s1, a0
|
|
li a0, 0
|
|
mv a1, s1
|
|
call merge_sort
|
|
mv a0, s1
|
|
mv a1, s0
|
|
call putarray
|
|
li a0, 0
|
|
ld ra, 24(sp)
|
|
ld s0, 16(sp)
|
|
ld s1, 8(sp)
|
|
addi sp, sp, 32
|
|
ret
|
|
.Lfunc_end1:
|
|
.size main, .Lfunc_end1-main
|
|
|
|
.type buf,@object
|
|
.bss
|
|
.globl buf
|
|
.p2align 2
|
|
buf:
|
|
.zero 800
|
|
.size buf, 800
|
|
|
|
.type _sysy_start,@object
|
|
.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
|
|
.addrsig_sym buf
|