726 lines
9.6 KiB
ArmAsm
726 lines
9.6 KiB
ArmAsm
.file "18_prim.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 find
|
|
.type find, @function
|
|
find:
|
|
addi sp,sp,-64
|
|
sd s0,48(sp)
|
|
sd s1,40(sp)
|
|
lla s0,fa
|
|
slli s1,a0,2
|
|
add a5,s0,s1
|
|
lw a5,0(a5)
|
|
sd ra,56(sp)
|
|
sd s2,32(sp)
|
|
sd s3,24(sp)
|
|
sd s4,16(sp)
|
|
sd s5,8(sp)
|
|
sd s6,0(sp)
|
|
beq a5,a0,.L23
|
|
slli s2,a5,2
|
|
add a4,s0,s2
|
|
lw a0,0(a4)
|
|
beq a5,a0,.L18
|
|
slli s3,a0,2
|
|
add a5,s0,s3
|
|
lw a5,0(a5)
|
|
beq a0,a5,.L19
|
|
slli s4,a5,2
|
|
add a4,s0,s4
|
|
lw a0,0(a4)
|
|
beq a5,a0,.L20
|
|
slli s5,a0,2
|
|
add a5,s0,s5
|
|
lw a5,0(a5)
|
|
beq a0,a5,.L21
|
|
slli s6,a5,2
|
|
add s6,s0,s6
|
|
lw a0,0(s6)
|
|
beq a5,a0,.L22
|
|
call find
|
|
sw a0,0(s6)
|
|
.L22:
|
|
add s5,s0,s5
|
|
sw a0,0(s5)
|
|
.L21:
|
|
add s4,s0,s4
|
|
sw a0,0(s4)
|
|
.L20:
|
|
add s3,s0,s3
|
|
sw a0,0(s3)
|
|
.L19:
|
|
add s2,s0,s2
|
|
sw a0,0(s2)
|
|
.L18:
|
|
add s0,s0,s1
|
|
sw a0,0(s0)
|
|
.L17:
|
|
ld ra,56(sp)
|
|
ld s0,48(sp)
|
|
ld s1,40(sp)
|
|
ld s2,32(sp)
|
|
ld s3,24(sp)
|
|
ld s4,16(sp)
|
|
ld s5,8(sp)
|
|
ld s6,0(sp)
|
|
addi sp,sp,64
|
|
jr ra
|
|
.L23:
|
|
mv a0,a5
|
|
j .L17
|
|
.size find, .-find
|
|
.align 1
|
|
.globl same
|
|
.type same, @function
|
|
same:
|
|
addi sp,sp,-96
|
|
sd s0,80(sp)
|
|
sd s3,56(sp)
|
|
lla s0,fa
|
|
slli s3,a0,2
|
|
add a5,s0,s3
|
|
sd s1,72(sp)
|
|
lw s1,0(a5)
|
|
sd ra,88(sp)
|
|
sd s2,64(sp)
|
|
sd s4,48(sp)
|
|
sd s5,40(sp)
|
|
sd s6,32(sp)
|
|
sd s7,24(sp)
|
|
beq a0,s1,.L28
|
|
slli s4,s1,2
|
|
add a5,s0,s4
|
|
lw a5,0(a5)
|
|
beq s1,a5,.L29
|
|
slli s5,a5,2
|
|
add a4,s0,s5
|
|
lw s1,0(a4)
|
|
beq a5,s1,.L30
|
|
slli s6,s1,2
|
|
add a5,s0,s6
|
|
lw a5,0(a5)
|
|
beq s1,a5,.L31
|
|
slli s7,a5,2
|
|
add s7,s0,s7
|
|
lw s1,0(s7)
|
|
beq a5,s1,.L32
|
|
mv a0,s1
|
|
sd a1,8(sp)
|
|
call find
|
|
ld a1,8(sp)
|
|
mv s1,a0
|
|
sw a0,0(s7)
|
|
.L32:
|
|
add s6,s0,s6
|
|
sw s1,0(s6)
|
|
.L31:
|
|
add s5,s0,s5
|
|
sw s1,0(s5)
|
|
.L30:
|
|
add s4,s0,s4
|
|
sw s1,0(s4)
|
|
.L29:
|
|
add s3,s0,s3
|
|
sw s1,0(s3)
|
|
.L28:
|
|
slli s3,a1,2
|
|
add a5,s0,s3
|
|
lw a0,0(a5)
|
|
beq a1,a0,.L33
|
|
slli s2,a0,2
|
|
add a5,s0,s2
|
|
lw a5,0(a5)
|
|
beq a0,a5,.L34
|
|
slli s4,a5,2
|
|
add a4,s0,s4
|
|
lw a0,0(a4)
|
|
beq a5,a0,.L35
|
|
slli s5,a0,2
|
|
add a5,s0,s5
|
|
lw a5,0(a5)
|
|
beq a0,a5,.L36
|
|
slli s6,a5,2
|
|
add s6,s0,s6
|
|
lw a0,0(s6)
|
|
beq a5,a0,.L37
|
|
call find
|
|
sw a0,0(s6)
|
|
.L37:
|
|
add s5,s0,s5
|
|
sw a0,0(s5)
|
|
.L36:
|
|
add s4,s0,s4
|
|
sw a0,0(s4)
|
|
.L35:
|
|
add s2,s0,s2
|
|
sw a0,0(s2)
|
|
.L34:
|
|
add s0,s0,s3
|
|
sw a0,0(s0)
|
|
.L33:
|
|
ld ra,88(sp)
|
|
ld s0,80(sp)
|
|
sub a0,a0,s1
|
|
ld s2,64(sp)
|
|
ld s1,72(sp)
|
|
ld s3,56(sp)
|
|
ld s4,48(sp)
|
|
ld s5,40(sp)
|
|
ld s6,32(sp)
|
|
ld s7,24(sp)
|
|
seqz a0,a0
|
|
addi sp,sp,96
|
|
jr ra
|
|
.size same, .-same
|
|
.align 1
|
|
.globl prim
|
|
.type prim, @function
|
|
prim:
|
|
addi sp,sp,-144
|
|
sd s2,112(sp)
|
|
lla s2,.LANCHOR0
|
|
lw t0,0(s2)
|
|
sd ra,136(sp)
|
|
sd s0,128(sp)
|
|
sd s1,120(sp)
|
|
sd s3,104(sp)
|
|
sd s4,96(sp)
|
|
sd s5,88(sp)
|
|
sd s6,80(sp)
|
|
sd s7,72(sp)
|
|
sd s8,64(sp)
|
|
sd s9,56(sp)
|
|
sd s10,48(sp)
|
|
sd s11,40(sp)
|
|
ble t0,zero,.L48
|
|
li t2,0
|
|
addiw t2,t2,1
|
|
lla a6,c+4
|
|
lla t1,u+4
|
|
lla a7,v+4
|
|
li s0,0
|
|
addiw s3,t0,-1
|
|
lla s1,c+8
|
|
bge t2,t0,.L94
|
|
.L47:
|
|
subw a0,s3,t2
|
|
slli a0,a0,32
|
|
srli a0,a0,32
|
|
add a0,a0,s0
|
|
slli a0,a0,2
|
|
add a0,a0,s1
|
|
mv a3,a7
|
|
mv a4,t1
|
|
mv a5,a6
|
|
.L51:
|
|
lw a1,0(a5)
|
|
lw a2,-4(a6)
|
|
ble a2,a1,.L50
|
|
lw t6,0(a4)
|
|
lw t5,0(a3)
|
|
lw t4,-4(t1)
|
|
lw t3,-4(a7)
|
|
sw t6,-4(t1)
|
|
sw t5,-4(a7)
|
|
sw a1,-4(a6)
|
|
sw t4,0(a4)
|
|
sw t3,0(a3)
|
|
sw a2,0(a5)
|
|
.L50:
|
|
addi a5,a5,4
|
|
addi a4,a4,4
|
|
addi a3,a3,4
|
|
bne a0,a5,.L51
|
|
.L91:
|
|
addiw t2,t2,1
|
|
addi s0,s0,1
|
|
addi a6,a6,4
|
|
addi t1,t1,4
|
|
addi a7,a7,4
|
|
blt t2,t0,.L47
|
|
.L94:
|
|
bne t2,t0,.L91
|
|
.L48:
|
|
lw a3,4(s2)
|
|
ble a3,zero,.L46
|
|
lla a4,fa+4
|
|
addiw a3,a3,1
|
|
li a5,1
|
|
.L54:
|
|
sw a5,0(a4)
|
|
addiw a5,a5,1
|
|
addi a4,a4,4
|
|
bne a5,a3,.L54
|
|
.L46:
|
|
lla s5,v
|
|
lla s8,c
|
|
lla s4,u
|
|
li s9,0
|
|
li s7,0
|
|
lla s0,fa
|
|
.L70:
|
|
bge s7,t0,.L95
|
|
.L77:
|
|
lw a5,0(s4)
|
|
lw s6,0(s5)
|
|
slli s3,a5,2
|
|
add a4,s0,s3
|
|
lw s1,0(a4)
|
|
beq a5,s1,.L55
|
|
slli s10,s1,2
|
|
add a5,s0,s10
|
|
lw a5,0(a5)
|
|
beq s1,a5,.L56
|
|
slli s11,a5,2
|
|
add a4,s0,s11
|
|
lw s1,0(a4)
|
|
beq a5,s1,.L57
|
|
slli a5,s1,2
|
|
add a4,s0,a5
|
|
lw a4,0(a4)
|
|
beq s1,a4,.L58
|
|
slli a3,a4,2
|
|
add a2,s0,a3
|
|
lw s1,0(a2)
|
|
beq a4,s1,.L59
|
|
slli a4,s1,2
|
|
add a2,s0,a4
|
|
lw a2,0(a2)
|
|
beq s1,a2,.L60
|
|
slli a1,a2,2
|
|
add a1,s0,a1
|
|
lw s1,0(a1)
|
|
sd a1,0(sp)
|
|
beq a2,s1,.L61
|
|
mv a0,s1
|
|
sd a4,24(sp)
|
|
sd a3,16(sp)
|
|
sd a5,8(sp)
|
|
call find
|
|
ld a1,0(sp)
|
|
ld a4,24(sp)
|
|
ld a3,16(sp)
|
|
ld a5,8(sp)
|
|
mv s1,a0
|
|
sw a0,0(a1)
|
|
.L61:
|
|
add a4,s0,a4
|
|
sw s1,0(a4)
|
|
.L60:
|
|
add a3,s0,a3
|
|
sw s1,0(a3)
|
|
.L59:
|
|
add a5,s0,a5
|
|
sw s1,0(a5)
|
|
.L58:
|
|
add s11,s0,s11
|
|
sw s1,0(s11)
|
|
.L57:
|
|
add s10,s0,s10
|
|
sw s1,0(s10)
|
|
.L56:
|
|
add a5,s0,s3
|
|
sw s1,0(a5)
|
|
.L55:
|
|
slli s3,s6,2
|
|
add a5,s0,s3
|
|
lw a0,0(a5)
|
|
beq s6,a0,.L62
|
|
slli s6,a0,2
|
|
add a5,s0,s6
|
|
lw a5,0(a5)
|
|
beq a0,a5,.L63
|
|
slli s10,a5,2
|
|
add a4,s0,s10
|
|
lw a0,0(a4)
|
|
beq a5,a0,.L64
|
|
slli s11,a0,2
|
|
add a5,s0,s11
|
|
lw a5,0(a5)
|
|
beq a0,a5,.L65
|
|
slli a4,a5,2
|
|
add a3,s0,a4
|
|
lw a0,0(a3)
|
|
beq a5,a0,.L66
|
|
slli a5,a0,2
|
|
add a3,s0,a5
|
|
lw a3,0(a3)
|
|
beq a0,a3,.L67
|
|
slli a2,a3,2
|
|
add a2,s0,a2
|
|
lw a0,0(a2)
|
|
sd a2,0(sp)
|
|
beq a3,a0,.L68
|
|
sd a5,16(sp)
|
|
sd a4,8(sp)
|
|
call find
|
|
ld a2,0(sp)
|
|
ld a5,16(sp)
|
|
ld a4,8(sp)
|
|
sw a0,0(a2)
|
|
.L68:
|
|
add a5,s0,a5
|
|
sw a0,0(a5)
|
|
.L67:
|
|
add a4,s0,a4
|
|
sw a0,0(a4)
|
|
.L66:
|
|
add s11,s0,s11
|
|
sw a0,0(s11)
|
|
.L65:
|
|
add s10,s0,s10
|
|
sw a0,0(s10)
|
|
.L64:
|
|
add s6,s0,s6
|
|
sw a0,0(s6)
|
|
.L63:
|
|
add a5,s0,s3
|
|
sw a0,0(a5)
|
|
.L62:
|
|
beq a0,s1,.L96
|
|
lw a3,0(s4)
|
|
lw a2,0(s8)
|
|
slli s10,a3,2
|
|
add a5,s0,s10
|
|
lw a5,0(a5)
|
|
addw s9,a2,s9
|
|
slli s1,a5,2
|
|
beq a3,a5,.L71
|
|
add a3,s0,s1
|
|
lw a2,0(a3)
|
|
beq a5,a2,.L72
|
|
slli s3,a2,2
|
|
add a5,s0,s3
|
|
lw a3,0(a5)
|
|
beq a2,a3,.L73
|
|
slli s6,a3,2
|
|
add a5,s0,s6
|
|
lw a5,0(a5)
|
|
beq a3,a5,.L74
|
|
slli s11,a5,2
|
|
add a4,s0,s11
|
|
lw a3,0(a4)
|
|
beq a5,a3,.L75
|
|
slli a5,a3,2
|
|
add a5,s0,a5
|
|
lw a0,0(a5)
|
|
sd a5,0(sp)
|
|
beq a3,a0,.L76
|
|
call find
|
|
ld a5,0(sp)
|
|
mv a3,a0
|
|
sw a0,0(a5)
|
|
.L76:
|
|
add s11,s0,s11
|
|
sw a3,0(s11)
|
|
.L75:
|
|
add s6,s0,s6
|
|
sw a3,0(s6)
|
|
.L74:
|
|
add s3,s0,s3
|
|
sw a3,0(s3)
|
|
.L73:
|
|
add s1,s0,s1
|
|
sw a3,0(s1)
|
|
mv a5,a3
|
|
slli s1,a3,2
|
|
.L72:
|
|
add a4,s0,s10
|
|
sw a5,0(a4)
|
|
.L71:
|
|
lw a5,0(s5)
|
|
lw t0,0(s2)
|
|
add s1,s0,s1
|
|
sw a5,0(s1)
|
|
addiw s7,s7,1
|
|
addi s5,s5,4
|
|
addi s8,s8,4
|
|
addi s4,s4,4
|
|
blt s7,t0,.L77
|
|
.L95:
|
|
ld ra,136(sp)
|
|
ld s0,128(sp)
|
|
ld s1,120(sp)
|
|
ld s2,112(sp)
|
|
ld s3,104(sp)
|
|
ld s4,96(sp)
|
|
ld s5,88(sp)
|
|
ld s6,80(sp)
|
|
ld s7,72(sp)
|
|
ld s8,64(sp)
|
|
ld s10,48(sp)
|
|
ld s11,40(sp)
|
|
mv a0,s9
|
|
ld s9,56(sp)
|
|
addi sp,sp,144
|
|
jr ra
|
|
.L96:
|
|
lw t0,0(s2)
|
|
j .L70
|
|
.size prim, .-prim
|
|
.section .text.startup,"ax",@progbits
|
|
.align 1
|
|
.globl main
|
|
.type main, @function
|
|
main:
|
|
addi sp,sp,-80
|
|
sd ra,72(sp)
|
|
sd s0,64(sp)
|
|
sd s1,56(sp)
|
|
sd s2,48(sp)
|
|
sd s3,40(sp)
|
|
sd s4,32(sp)
|
|
sd s5,24(sp)
|
|
sd s6,16(sp)
|
|
sd s7,8(sp)
|
|
sd s8,0(sp)
|
|
call quick_read
|
|
call quick_read
|
|
ble a0,zero,.L98
|
|
lla s2,c
|
|
slli a0,a0,2
|
|
lla s4,v
|
|
lla s3,u
|
|
add s5,a0,s2
|
|
li s0,9
|
|
li s1,45
|
|
li s6,48
|
|
.L115:
|
|
call getch@plt
|
|
addiw a5,a0,-48
|
|
li s8,0
|
|
bleu a5,s0,.L99
|
|
.L101:
|
|
bne a0,s1,.L100
|
|
li s8,1
|
|
.L100:
|
|
call getch@plt
|
|
addiw a5,a0,-48
|
|
bgtu a5,s0,.L101
|
|
.L99:
|
|
li a5,0
|
|
.L102:
|
|
slliw s7,a5,2
|
|
addw s7,s7,a5
|
|
slliw s7,s7,1
|
|
addw s7,s7,a0
|
|
call getch@plt
|
|
addiw a4,a0,-48
|
|
addiw a5,s7,-48
|
|
bleu a4,s0,.L102
|
|
beq s8,zero,.L103
|
|
subw a5,s6,s7
|
|
.L103:
|
|
sw a5,0(s3)
|
|
call getch@plt
|
|
addiw a5,a0,-48
|
|
li s8,0
|
|
bleu a5,s0,.L104
|
|
.L106:
|
|
bne a0,s1,.L105
|
|
li s8,1
|
|
.L105:
|
|
call getch@plt
|
|
addiw a5,a0,-48
|
|
bgtu a5,s0,.L106
|
|
.L104:
|
|
li a5,0
|
|
.L107:
|
|
slliw s7,a5,2
|
|
addw s7,s7,a5
|
|
slliw s7,s7,1
|
|
addw s7,s7,a0
|
|
call getch@plt
|
|
addiw a4,a0,-48
|
|
addiw a5,s7,-48
|
|
bleu a4,s0,.L107
|
|
beq s8,zero,.L108
|
|
subw a5,s6,s7
|
|
.L108:
|
|
sw a5,0(s4)
|
|
call getch@plt
|
|
addiw a5,a0,-48
|
|
li s8,0
|
|
bleu a5,s0,.L109
|
|
.L111:
|
|
bne a0,s1,.L110
|
|
li s8,1
|
|
.L110:
|
|
call getch@plt
|
|
addiw a5,a0,-48
|
|
bgtu a5,s0,.L111
|
|
.L109:
|
|
li a5,0
|
|
.L112:
|
|
slliw s7,a5,2
|
|
addw s7,s7,a5
|
|
slliw s7,s7,1
|
|
addw s7,s7,a0
|
|
call getch@plt
|
|
addiw a3,a0,-48
|
|
addiw a5,s7,-48
|
|
bleu a3,s0,.L112
|
|
beq s8,zero,.L113
|
|
subw s7,s6,s7
|
|
sw s7,0(s2)
|
|
addi s2,s2,4
|
|
addi s4,s4,4
|
|
addi s3,s3,4
|
|
bne s5,s2,.L115
|
|
.L98:
|
|
ld s0,64(sp)
|
|
ld ra,72(sp)
|
|
ld s1,56(sp)
|
|
ld s2,48(sp)
|
|
ld s3,40(sp)
|
|
ld s4,32(sp)
|
|
ld s5,24(sp)
|
|
ld s6,16(sp)
|
|
ld s7,8(sp)
|
|
ld s8,0(sp)
|
|
addi sp,sp,80
|
|
tail prim
|
|
.L113:
|
|
sw a5,0(s2)
|
|
addi s2,s2,4
|
|
addi s4,s4,4
|
|
addi s3,s3,4
|
|
bne s5,s2,.L115
|
|
j .L98
|
|
.size main, .-main
|
|
.globl fa
|
|
.globl c
|
|
.globl v
|
|
.globl u
|
|
.globl m
|
|
.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 m, @object
|
|
.size m, 4
|
|
m:
|
|
.zero 4
|
|
.type n, @object
|
|
.size n, 4
|
|
n:
|
|
.zero 4
|
|
.type fa, @object
|
|
.size fa, 4020
|
|
fa:
|
|
.zero 4020
|
|
.zero 4
|
|
.type c, @object
|
|
.size c, 4020
|
|
c:
|
|
.zero 4020
|
|
.zero 4
|
|
.type v, @object
|
|
.size v, 4020
|
|
v:
|
|
.zero 4020
|
|
.zero 4
|
|
.type u, @object
|
|
.size u, 4020
|
|
u:
|
|
.zero 4020
|
|
.type _sysy_idx, @object
|
|
.size _sysy_idx, 4
|
|
_sysy_idx:
|
|
.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
|