612 lines
8.1 KiB
ArmAsm
612 lines
8.1 KiB
ArmAsm
.file "10_DFS.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 add_edge
|
|
.type add_edge, @function
|
|
add_edge:
|
|
lla t1,.LANCHOR0
|
|
lw a5,0(t1)
|
|
lla a4,head
|
|
slli a3,a0,2
|
|
add a3,a4,a3
|
|
slli a2,a1,2
|
|
lw t5,0(a3)
|
|
add a4,a4,a2
|
|
sw a5,0(a3)
|
|
addiw a6,a5,1
|
|
slli a7,a5,2
|
|
lw t4,0(a4)
|
|
lla a2,to
|
|
lla a3,next
|
|
add t6,a2,a7
|
|
mv t3,a6
|
|
add a7,a3,a7
|
|
slli a6,a6,2
|
|
sw a1,0(t6)
|
|
sw t5,0(a7)
|
|
add a2,a2,a6
|
|
add a3,a3,a6
|
|
addiw a5,a5,2
|
|
sw a0,0(a2)
|
|
sw t4,0(a3)
|
|
sw t3,0(a4)
|
|
sw a5,0(t1)
|
|
ret
|
|
.size add_edge, .-add_edge
|
|
.align 1
|
|
.globl init
|
|
.type init, @function
|
|
init:
|
|
li a2,4096
|
|
addi a2,a2,-76
|
|
li a1,255
|
|
lla a0,head
|
|
tail memset@plt
|
|
.size init, .-init
|
|
.align 1
|
|
.globl clear
|
|
.type clear, @function
|
|
clear:
|
|
lw a2,.LANCHOR0+4
|
|
ble a2,zero,.L18
|
|
slli a5,a2,32
|
|
srli a2,a5,30
|
|
li a1,0
|
|
lla a0,vis+4
|
|
tail memset@plt
|
|
.L18:
|
|
ret
|
|
.size clear, .-clear
|
|
.align 1
|
|
.globl same
|
|
.type same, @function
|
|
same:
|
|
addi sp,sp,-144
|
|
sd s4,96(sp)
|
|
slli a5,a0,2
|
|
lla s4,vis
|
|
sd ra,136(sp)
|
|
sd s0,128(sp)
|
|
sd s1,120(sp)
|
|
sd s2,112(sp)
|
|
sd s3,104(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)
|
|
add a4,s4,a5
|
|
li a3,1
|
|
sw a3,0(a4)
|
|
beq a0,a1,.L21
|
|
lla a3,head
|
|
add a5,a3,a5
|
|
lw a6,0(a5)
|
|
li a5,-1
|
|
mv s9,a1
|
|
lla s5,to
|
|
lla s1,next
|
|
bne a6,a5,.L22
|
|
j .L49
|
|
.L24:
|
|
add a4,a4,a6
|
|
lw a6,0(a4)
|
|
li a5,-1
|
|
beq a6,a5,.L49
|
|
.L22:
|
|
slli a6,a6,2
|
|
add a5,s5,a6
|
|
lw a2,0(a5)
|
|
mv a4,s1
|
|
slli a5,a2,2
|
|
add a1,s4,a5
|
|
lw a0,0(a1)
|
|
bne a0,zero,.L24
|
|
li a4,1
|
|
sw a4,0(a1)
|
|
beq s9,a2,.L21
|
|
add a5,a3,a5
|
|
lw a2,0(a5)
|
|
li a5,-1
|
|
lla a4,next
|
|
bne a2,a5,.L48
|
|
j .L24
|
|
.L25:
|
|
add a2,a4,a2
|
|
lw a2,0(a2)
|
|
li a5,-1
|
|
beq a2,a5,.L24
|
|
.L48:
|
|
slli a2,a2,2
|
|
add a5,s5,a2
|
|
lw a1,0(a5)
|
|
mv a4,s1
|
|
slli a5,a1,2
|
|
add a0,s4,a5
|
|
lw a7,0(a0)
|
|
bne a7,zero,.L25
|
|
li a4,1
|
|
sw a4,0(a0)
|
|
beq s9,a1,.L21
|
|
add a5,a3,a5
|
|
lw s11,0(a5)
|
|
li a5,-1
|
|
beq s11,a5,.L54
|
|
li s10,1
|
|
j .L47
|
|
.L27:
|
|
add s11,a4,s11
|
|
lw s11,0(s11)
|
|
li a5,-1
|
|
beq s11,a5,.L25
|
|
.L47:
|
|
slli s11,s11,2
|
|
add a5,s5,s11
|
|
lw a1,0(a5)
|
|
mv a4,s1
|
|
slli a5,a1,2
|
|
add a0,s4,a5
|
|
lw a7,0(a0)
|
|
bne a7,zero,.L27
|
|
sw s10,0(a0)
|
|
beq s9,a1,.L21
|
|
add a5,a3,a5
|
|
lw s8,0(a5)
|
|
li a5,-1
|
|
beq s8,a5,.L56
|
|
li s3,-1
|
|
j .L46
|
|
.L29:
|
|
add s8,a4,s8
|
|
lw s8,0(s8)
|
|
beq s8,s3,.L27
|
|
.L46:
|
|
slli s8,s8,2
|
|
add a5,s5,s8
|
|
lw a1,0(a5)
|
|
mv a4,s1
|
|
slli a5,a1,2
|
|
add a0,s4,a5
|
|
lw a7,0(a0)
|
|
bne a7,zero,.L29
|
|
sw s10,0(a0)
|
|
beq s9,a1,.L21
|
|
add a5,a3,a5
|
|
lw s7,0(a5)
|
|
lla a4,next
|
|
bne s7,s3,.L45
|
|
j .L29
|
|
.L31:
|
|
add s7,a4,s7
|
|
lw s7,0(s7)
|
|
beq s7,s3,.L29
|
|
.L45:
|
|
slli s7,s7,2
|
|
add a5,s5,s7
|
|
lw a1,0(a5)
|
|
mv a4,s1
|
|
slli a5,a1,2
|
|
add a0,s4,a5
|
|
lw a7,0(a0)
|
|
bne a7,zero,.L31
|
|
sw s10,0(a0)
|
|
beq s9,a1,.L21
|
|
add a5,a3,a5
|
|
lw s6,0(a5)
|
|
bne s6,s3,.L44
|
|
j .L31
|
|
.L33:
|
|
add s6,a4,s6
|
|
lw s6,0(s6)
|
|
beq s6,s3,.L31
|
|
.L44:
|
|
slli s6,s6,2
|
|
add a5,s5,s6
|
|
lw a1,0(a5)
|
|
mv a4,s1
|
|
slli a5,a1,2
|
|
add a0,s4,a5
|
|
lw a7,0(a0)
|
|
bne a7,zero,.L33
|
|
sw s10,0(a0)
|
|
beq s9,a1,.L21
|
|
add a5,a3,a5
|
|
lw a5,0(a5)
|
|
bne a5,s3,.L43
|
|
j .L33
|
|
.L35:
|
|
add a5,a4,s2
|
|
lw a5,0(a5)
|
|
beq a5,s3,.L33
|
|
.L43:
|
|
slli s2,a5,2
|
|
add a5,s5,s2
|
|
lw a1,0(a5)
|
|
mv a4,s1
|
|
slli a5,a1,2
|
|
add a0,s4,a5
|
|
lw a7,0(a0)
|
|
bne a7,zero,.L35
|
|
sw s10,0(a0)
|
|
beq s9,a1,.L21
|
|
add a5,a3,a5
|
|
lw a5,0(a5)
|
|
bne a5,s3,.L42
|
|
j .L35
|
|
.L37:
|
|
add a5,a4,s0
|
|
lw a5,0(a5)
|
|
beq a5,s3,.L35
|
|
.L42:
|
|
slli s0,a5,2
|
|
add a5,s5,s0
|
|
lw a1,0(a5)
|
|
mv a4,s1
|
|
slli a5,a1,2
|
|
add a0,s4,a5
|
|
lw a7,0(a0)
|
|
bne a7,zero,.L37
|
|
sw s10,0(a0)
|
|
beq s9,a1,.L21
|
|
add a5,a3,a5
|
|
lw a5,0(a5)
|
|
bne a5,s3,.L40
|
|
j .L37
|
|
.L41:
|
|
add a5,s1,a5
|
|
lw a5,0(a5)
|
|
mv a4,s1
|
|
beq a5,s3,.L37
|
|
.L40:
|
|
slli a5,a5,2
|
|
add a4,s5,a5
|
|
lw a0,0(a4)
|
|
slli a4,a0,2
|
|
add a4,s4,a4
|
|
lw a4,0(a4)
|
|
bne a4,zero,.L41
|
|
mv a1,s9
|
|
sd a2,24(sp)
|
|
sd a6,16(sp)
|
|
sd a5,8(sp)
|
|
call same
|
|
ld a5,8(sp)
|
|
ld a6,16(sp)
|
|
ld a2,24(sp)
|
|
lla a3,head
|
|
beq a0,zero,.L41
|
|
.L21:
|
|
li a0,1
|
|
.L77:
|
|
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 s9,56(sp)
|
|
ld s10,48(sp)
|
|
ld s11,40(sp)
|
|
addi sp,sp,144
|
|
jr ra
|
|
.L49:
|
|
li a0,0
|
|
j .L77
|
|
.L56:
|
|
lla a4,next
|
|
j .L27
|
|
.L54:
|
|
lla a4,next
|
|
j .L25
|
|
.size same, .-same
|
|
.section .text.startup,"ax",@progbits
|
|
.align 1
|
|
.globl main
|
|
.type main, @function
|
|
main:
|
|
addi sp,sp,-96
|
|
sd ra,88(sp)
|
|
sd s0,80(sp)
|
|
sd s2,64(sp)
|
|
sd s1,72(sp)
|
|
sd s3,56(sp)
|
|
sd s4,48(sp)
|
|
sd s5,40(sp)
|
|
sd s6,32(sp)
|
|
sd s7,24(sp)
|
|
sd s8,16(sp)
|
|
sd s9,8(sp)
|
|
lla s2,.LANCHOR0
|
|
call quick_read
|
|
sw a0,4(s2)
|
|
call quick_read
|
|
li a2,4096
|
|
mv s0,a0
|
|
addi a2,a2,-76
|
|
li a1,255
|
|
lla a0,head
|
|
sw s0,8(s2)
|
|
call memset@plt
|
|
beq s0,zero,.L80
|
|
li s0,81
|
|
li s1,85
|
|
lla s5,to
|
|
lla s4,next
|
|
lla s3,head
|
|
j .L97
|
|
.L121:
|
|
beq a0,s1,.L82
|
|
.L97:
|
|
call getch@plt
|
|
bne a0,s0,.L121
|
|
call quick_read
|
|
mv s6,a0
|
|
call quick_read
|
|
lw a2,4(s2)
|
|
mv s7,a0
|
|
ble a2,zero,.L85
|
|
slli a5,a2,32
|
|
srli a2,a5,30
|
|
li a1,0
|
|
lla a0,vis+4
|
|
call memset@plt
|
|
.L85:
|
|
mv a1,s7
|
|
mv a0,s6
|
|
call same
|
|
call putint@plt
|
|
li a0,10
|
|
call putch@plt
|
|
.L88:
|
|
lw a5,8(s2)
|
|
addiw a4,a5,-1
|
|
sw a4,8(s2)
|
|
bne a4,zero,.L97
|
|
.L80:
|
|
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)
|
|
li a0,0
|
|
addi sp,sp,96
|
|
jr ra
|
|
.L82:
|
|
call getch@plt
|
|
addiw a4,a0,-48
|
|
li a5,9
|
|
li s8,0
|
|
li s7,45
|
|
li s6,9
|
|
bleu a4,a5,.L87
|
|
.L86:
|
|
bne a0,s7,.L89
|
|
li s8,1
|
|
.L89:
|
|
call getch@plt
|
|
addiw a5,a0,-48
|
|
bgtu a5,s6,.L86
|
|
.L87:
|
|
li s6,0
|
|
li s9,9
|
|
.L90:
|
|
slliw s7,s6,2
|
|
addw s7,s7,s6
|
|
slliw s7,s7,1
|
|
addw s7,s7,a0
|
|
call getch@plt
|
|
addiw a5,a0,-48
|
|
addiw s6,s7,-48
|
|
bleu a5,s9,.L90
|
|
beq s8,zero,.L91
|
|
li s6,48
|
|
subw s6,s6,s7
|
|
.L91:
|
|
call getch@plt
|
|
addiw a4,a0,-48
|
|
li a5,9
|
|
li s8,0
|
|
bleu a4,a5,.L92
|
|
li s9,45
|
|
li s7,9
|
|
.L94:
|
|
bne a0,s9,.L93
|
|
li s8,1
|
|
.L93:
|
|
call getch@plt
|
|
addiw a5,a0,-48
|
|
bgtu a5,s7,.L94
|
|
.L92:
|
|
li a5,0
|
|
li s9,9
|
|
.L95:
|
|
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,s9,.L95
|
|
beq s8,zero,.L96
|
|
li a5,48
|
|
subw a5,a5,s7
|
|
.L96:
|
|
lw a4,0(s2)
|
|
slli a3,s6,2
|
|
add a3,s3,a3
|
|
slli a2,a5,2
|
|
lw a7,0(a3)
|
|
addiw a0,a4,1
|
|
sw a4,0(a3)
|
|
add a2,s3,a2
|
|
slli a1,a4,2
|
|
lw a6,0(a2)
|
|
sext.w a3,a0
|
|
slli a3,a3,2
|
|
add t1,s5,a1
|
|
add a1,s4,a1
|
|
sw a5,0(t1)
|
|
sw a7,0(a1)
|
|
add a5,s5,a3
|
|
addiw a4,a4,2
|
|
add a3,s4,a3
|
|
sw s6,0(a5)
|
|
sw a6,0(a3)
|
|
sw a0,0(a2)
|
|
sw a4,0(s2)
|
|
j .L88
|
|
.size main, .-main
|
|
.globl vis
|
|
.globl cnt
|
|
.globl head
|
|
.globl next
|
|
.globl to
|
|
.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 cnt, @object
|
|
.size cnt, 4
|
|
cnt:
|
|
.zero 4
|
|
.type n, @object
|
|
.size n, 4
|
|
n:
|
|
.zero 4
|
|
.type m, @object
|
|
.size m, 4
|
|
m:
|
|
.zero 4
|
|
.zero 4
|
|
.type vis, @object
|
|
.size vis, 4020
|
|
vis:
|
|
.zero 4020
|
|
.zero 4
|
|
.type head, @object
|
|
.size head, 4020
|
|
head:
|
|
.zero 4020
|
|
.zero 4
|
|
.type next, @object
|
|
.size next, 20020
|
|
next:
|
|
.zero 20020
|
|
.zero 4
|
|
.type to, @object
|
|
.size to, 20020
|
|
to:
|
|
.zero 20020
|
|
.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
|