sysy-data/functional_c/asm/74_kmp.s

378 lines
5.4 KiB
ArmAsm

.text
.attribute 4, 16
.attribute 5, "rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0"
.file "74_kmp.sy"
.globl get_next
.p2align 1
.type get_next,@function
get_next:
li a6, -1
sw a6, 0(a1)
lw a5, 0(a0)
beqz a5, .LBB0_6
li a7, 0
srli a4, a6, 32
j .LBB0_3
.LBB0_2:
addiw a4, a4, 1
addiw a7, a7, 1
slli a2, a7, 2
add a2, a2, a1
sw a4, 0(a2)
slli a2, a7, 2
add a2, a2, a0
lw a5, 0(a2)
beqz a5, .LBB0_6
.LBB0_3:
sext.w a2, a4
beq a2, a6, .LBB0_2
slli a2, a2, 2
add a3, a0, a2
lw a3, 0(a3)
beq a5, a3, .LBB0_2
add a2, a2, a1
lw a4, 0(a2)
slli a2, a7, 2
add a2, a2, a0
lw a5, 0(a2)
bnez a5, .LBB0_3
.LBB0_6:
ret
.Lfunc_end0:
.size get_next, .Lfunc_end0-get_next
.globl KMP
.p2align 1
.type KMP,@function
KMP:
lui a2, 4
addiw a2, a2, 16
sub sp, sp, a2
li a6, -1
sw a6, 16(sp)
lw t1, 0(a0)
beqz t1, .LBB1_6
li t0, 0
srli a3, a6, 32
addi a7, sp, 16
mv a2, t1
j .LBB1_3
.LBB1_2:
addiw a3, a3, 1
addiw t0, t0, 1
slli a2, t0, 2
add a2, a2, a7
sw a3, 0(a2)
slli a2, t0, 2
add a2, a2, a0
lw a2, 0(a2)
beqz a2, .LBB1_6
.LBB1_3:
sext.w a5, a3
beq a5, a6, .LBB1_2
slli a5, a5, 2
add a4, a0, a5
lw a4, 0(a4)
beq a2, a4, .LBB1_2
add a2, a7, a5
lw a3, 0(a2)
slli a2, t0, 2
add a2, a2, a0
lw a2, 0(a2)
bnez a2, .LBB1_3
.LBB1_6:
lw a5, 0(a1)
beqz a5, .LBB1_14
li a3, 0
li a4, 0
li t0, -1
srli a6, t0, 32
addi a7, sp, 16
bne t1, a5, .LBB1_10
.LBB1_8:
addiw a4, a4, 1
slli a2, a4, 2
add a2, a2, a0
lw a2, 0(a2)
addiw a3, a3, 1
beqz a2, .LBB1_16
slli a2, a3, 2
add a2, a2, a1
lw a5, 0(a2)
bnez a5, .LBB1_13
j .LBB1_15
.LBB1_10:
slli a2, a4, 2
add a2, a2, a7
lw a2, 0(a2)
li a4, 0
beq a2, t0, .LBB1_12
mv a4, a2
.LBB1_12:
addi a2, a2, 1
seqz a2, a2
addw a3, a3, a2
slli a2, a3, 2
add a2, a2, a1
lw a5, 0(a2)
beqz a5, .LBB1_15
.LBB1_13:
slli a2, a4, 2
add a2, a2, a0
lw t1, 0(a2)
bne t1, a5, .LBB1_10
j .LBB1_8
.LBB1_14:
srli a3, a6, 32
j .LBB1_16
.LBB1_15:
mv a3, a6
.LBB1_16:
sext.w a0, a3
lui a1, 4
addiw a1, a1, 16
add sp, sp, a1
ret
.Lfunc_end1:
.size KMP, .Lfunc_end1-KMP
.globl read_str
.p2align 1
.type read_str,@function
read_str:
addi sp, sp, -32
sd ra, 24(sp)
sd s0, 16(sp)
sd s1, 8(sp)
sd s2, 0(sp)
mv s0, a0
li s1, -1
li s2, 10
.LBB2_1:
call getch
sw a0, 0(s0)
addi s1, s1, 1
addi s0, s0, 4
bne a0, s2, .LBB2_1
sext.w a0, s1
sw zero, -4(s0)
ld ra, 24(sp)
ld s0, 16(sp)
ld s1, 8(sp)
ld s2, 0(sp)
addi sp, sp, 32
ret
.Lfunc_end2:
.size read_str, .Lfunc_end2-read_str
.globl main
.p2align 1
.type main,@function
main:
addi sp, sp, -2032
sd ra, 2024(sp)
sd s0, 2016(sp)
sd s1, 2008(sp)
lui a0, 12
addiw a0, a0, -2000
sub sp, sp, a0
lui a0, 4
addiw a0, a0, 8
add s0, sp, a0
li s1, 10
.LBB3_1:
call getch
sw a0, 0(s0)
addi s0, s0, 4
bne a0, s1, .LBB3_1
sw zero, -4(s0)
addi s0, sp, 8
li s1, 10
.LBB3_3:
call getch
sw a0, 0(s0)
addi s0, s0, 4
bne a0, s1, .LBB3_3
lui a0, 4
addiw a0, a0, 8
add a0, a0, sp
lw a4, 0(a0)
sw zero, -4(s0)
li a6, -1
lui a0, 8
addiw a0, a0, 8
add a0, a0, sp
sw a6, 0(a0)
beqz a4, .LBB3_10
li a2, 0
srli a5, a6, 32
lui a0, 8
addiw a0, a0, 8
add a3, sp, a0
lui a0, 4
addiw a0, a0, 8
add s0, sp, a0
mv a0, a4
j .LBB3_7
.LBB3_6:
addiw a5, a5, 1
addiw a2, a2, 1
slli a0, a2, 2
add a0, a0, a3
sw a5, 0(a0)
slli a0, a2, 2
add a0, a0, s0
lw a0, 0(a0)
beqz a0, .LBB3_10
.LBB3_7:
sext.w s1, a5
beq s1, a6, .LBB3_6
slli s1, s1, 2
add a1, s0, s1
lw a1, 0(a1)
beq a0, a1, .LBB3_6
add a0, a3, s1
lw a5, 0(a0)
slli a0, a2, 2
add a0, a0, s0
lw a0, 0(a0)
bnez a0, .LBB3_7
.LBB3_10:
lw a5, 8(sp)
beqz a5, .LBB3_18
li a1, 0
li a3, 0
lui a0, 4
addiw a0, a0, 8
add a2, sp, a0
addi a0, sp, 8
li t0, -1
srli a6, t0, 32
lui a7, 8
addiw a7, a7, 8
add a7, a7, sp
bne a4, a5, .LBB3_14
.LBB3_12:
addiw a3, a3, 1
slli a4, a3, 2
add a4, a4, a2
lw a4, 0(a4)
addiw a1, a1, 1
beqz a4, .LBB3_20
slli a4, a1, 2
add a4, a4, a0
lw a5, 0(a4)
bnez a5, .LBB3_17
j .LBB3_19
.LBB3_14:
slli a3, a3, 2
add a3, a3, a7
lw a4, 0(a3)
li a3, 0
beq a4, t0, .LBB3_16
mv a3, a4
.LBB3_16:
addi a4, a4, 1
seqz a4, a4
addw a1, a1, a4
slli a4, a1, 2
add a4, a4, a0
lw a5, 0(a4)
beqz a5, .LBB3_19
.LBB3_17:
slli a4, a3, 2
add a4, a4, a2
lw a4, 0(a4)
bne a4, a5, .LBB3_14
j .LBB3_12
.LBB3_18:
srli a1, a6, 32
j .LBB3_20
.LBB3_19:
mv a1, a6
.LBB3_20:
sext.w a0, a1
call putint
li a0, 10
call putch
li a0, 0
lui a1, 12
addiw a1, a1, -2000
add sp, sp, a1
ld ra, 2024(sp)
ld s0, 2016(sp)
ld s1, 2008(sp)
addi sp, sp, 2032
ret
.Lfunc_end3:
.size main, .Lfunc_end3-main
.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