sysy-data/functional_c/asm/77_substr.s

738 lines
9.7 KiB
ArmAsm
Raw Permalink Normal View History

2024-06-14 13:10:27 +08:00
.file "77_substr.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 MAX
.type MAX, @function
MAX:
mv a5,a0
bge a0,a1,.L2
mv a5,a1
.L2:
sext.w a0,a5
ret
.size MAX, .-MAX
.align 1
.globl max_sum_nonadjacent
.type max_sum_nonadjacent, @function
max_sum_nonadjacent:
lw a3,0(a0)
lw a4,4(a0)
addi sp,sp,-64
sd zero,8(sp)
sd zero,16(sp)
sd zero,24(sp)
sd zero,32(sp)
sd zero,40(sp)
sd zero,48(sp)
sd zero,56(sp)
sw a3,0(sp)
beq a3,a4,.L5
mv a5,a3
blt a3,a4,.L76
.L6:
sext.w a4,a5
.L5:
sw a4,4(sp)
li a5,2
ble a1,a5,.L77
addiw a2,a1,-1
li a6,4
mv a5,a2
ble a1,a6,.L65
lw a6,8(a0)
addw a7,a6,a3
mv a3,a7
beq a4,a7,.L9
sext.w a3,a4
blt a4,a7,.L78
.L9:
lw a6,12(a0)
sw a3,8(sp)
addw a7,a6,a4
mv a4,a7
beq a3,a7,.L11
sext.w a4,a3
blt a3,a7,.L79
.L11:
sw a4,12(sp)
li a6,5
ble a2,a6,.L66
.L96:
lw a6,16(a0)
addw a7,a6,a3
mv a3,a7
beq a4,a7,.L13
sext.w a3,a4
blt a4,a7,.L80
.L13:
lw a6,20(a0)
sw a3,16(sp)
addw a7,a6,a4
mv a4,a7
beq a3,a7,.L15
sext.w a4,a3
blt a3,a7,.L81
.L15:
sw a4,20(sp)
li a6,7
ble a2,a6,.L67
.L97:
lw a6,24(a0)
addw a7,a6,a3
mv a3,a7
beq a4,a7,.L17
sext.w a3,a4
bge a4,a7,.L17
sext.w a3,a7
.L17:
lw a6,28(a0)
sw a3,24(sp)
addw a7,a6,a4
mv a4,a7
beq a3,a7,.L19
sext.w a4,a3
bge a3,a7,.L19
sext.w a4,a7
.L19:
sw a4,28(sp)
li a6,9
ble a2,a6,.L68
lw a6,32(a0)
addw a7,a6,a3
mv a3,a7
beq a4,a7,.L21
sext.w a3,a4
blt a4,a7,.L82
.L21:
lw a6,36(a0)
sw a3,32(sp)
addw a7,a6,a4
mv a4,a7
beq a3,a7,.L23
sext.w a4,a3
blt a3,a7,.L83
.L23:
sw a4,36(sp)
li a6,11
ble a2,a6,.L69
lw a6,40(a0)
addw a7,a6,a3
mv a3,a7
beq a4,a7,.L25
sext.w a3,a4
blt a4,a7,.L84
.L25:
lw a6,44(a0)
sw a3,40(sp)
addw a7,a6,a4
mv a4,a7
beq a3,a7,.L27
sext.w a4,a3
blt a3,a7,.L85
.L27:
sw a4,44(sp)
li a6,13
ble a2,a6,.L70
lw a6,48(a0)
addw a7,a6,a3
mv a3,a7
beq a4,a7,.L29
sext.w a3,a4
blt a4,a7,.L86
.L29:
lw a6,52(a0)
sw a3,48(sp)
addw a7,a6,a4
mv a4,a7
beq a3,a7,.L31
sext.w a4,a3
blt a3,a7,.L87
.L31:
sw a4,52(sp)
li a6,15
ble a2,a6,.L71
lw a2,56(a0)
mv a6,a4
addw a2,a2,a3
mv a3,a2
beq a2,a4,.L33
blt a2,a4,.L88
.L34:
sext.w a6,a3
.L33:
lw a3,60(a0)
sw a6,56(sp)
addw a2,a3,a4
mv a4,a2
beq a6,a2,.L35
sext.w a4,a6
blt a6,a2,.L89
.L35:
sw a4,60(sp)
li a4,16
.L8:
addiw a2,a4,-2
slli a2,a2,2
addi a3,a2,64
add a2,a3,sp
addiw a3,a4,-1
slli t1,a4,2
slli a3,a3,2
lw t3,-64(a2)
add a6,a0,t1
addi a2,a3,64
lw a7,0(a6)
add a2,a2,sp
lw a2,-64(a2)
addw t3,a7,t3
mv a7,t3
beq t3,a2,.L37
bge t3,a2,.L38
mv a7,a2
.L38:
sext.w a2,a7
.L37:
addi a7,t1,64
add a7,a7,sp
sw a2,-64(a7)
addi a7,a4,1
ble a1,a7,.L7
addi a3,a3,64
add a3,a3,sp
lw t3,-64(a3)
lw t4,4(a6)
addw t4,t3,t4
mv a3,t4
beq a2,t4,.L39
sext.w a3,a2
bge a2,t4,.L39
sext.w a3,t4
.L39:
slli a7,a7,2
addi a2,a7,64
add a2,a2,sp
sw a3,-64(a2)
addi a2,a4,2
ble a1,a2,.L7
addi t1,t1,64
add t1,t1,sp
lw t3,-64(t1)
lw t4,8(a6)
addw t4,t3,t4
mv t1,t4
beq a3,t4,.L41
sext.w t1,a3
bge a3,t4,.L41
sext.w t1,t4
.L41:
slli a2,a2,2
addi a3,a2,64
add a3,a3,sp
sw t1,-64(a3)
addi a3,a4,3
ble a1,a3,.L7
addi a7,a7,64
add a7,a7,sp
lw t3,-64(a7)
lw t4,12(a6)
addw t4,t3,t4
mv a7,t4
beq t1,t4,.L43
sext.w a7,t1
bge t1,t4,.L43
sext.w a7,t4
.L43:
slli a3,a3,2
addi t1,a3,64
add t1,t1,sp
sw a7,-64(t1)
addi t1,a4,4
ble a1,t1,.L7
addi a2,a2,64
add a2,a2,sp
lw t3,-64(a2)
lw t4,16(a6)
addw t4,t3,t4
mv a2,t4
beq a7,t4,.L45
sext.w a2,a7
bge a7,t4,.L45
sext.w a2,t4
.L45:
slli t1,t1,2
addi a7,t1,64
add a7,a7,sp
sw a2,-64(a7)
addi a7,a4,5
ble a1,a7,.L7
addi a3,a3,64
add a3,a3,sp
lw t3,-64(a3)
lw t4,20(a6)
addw t4,t3,t4
mv a3,t4
beq a2,t4,.L47
sext.w a3,a2
blt a2,t4,.L90
.L47:
slli a7,a7,2
addi a2,a7,64
add a2,a2,sp
sw a3,-64(a2)
addi a2,a4,6
ble a1,a2,.L7
addi t1,t1,64
add t1,t1,sp
lw t3,-64(t1)
lw t4,24(a6)
addw t4,t3,t4
mv t1,t4
beq a3,t4,.L49
sext.w t1,a3
blt a3,t4,.L91
.L49:
slli a2,a2,2
addi a3,a2,64
add a3,a3,sp
sw t1,-64(a3)
addi a3,a4,7
ble a1,a3,.L7
addi a7,a7,64
add a7,a7,sp
lw t3,-64(a7)
lw t4,28(a6)
addw t4,t3,t4
mv a7,t4
beq t1,t4,.L51
sext.w a7,t1
blt t1,t4,.L92
.L51:
slli a3,a3,2
addi t1,a3,64
add t1,t1,sp
sw a7,-64(t1)
addi t1,a4,8
ble a1,t1,.L7
addi a2,a2,64
add a2,a2,sp
lw t3,-64(a2)
lw t4,32(a6)
addw t4,t3,t4
mv a2,t4
beq a7,t4,.L53
sext.w a2,a7
blt a7,t4,.L93
.L53:
slli t1,t1,2
addi a7,t1,64
add a7,a7,sp
sw a2,-64(a7)
addi a7,a4,9
ble a1,a7,.L7
addi a3,a3,64
add a3,a3,sp
lw t3,-64(a3)
lw t4,36(a6)
addw t4,t3,t4
mv a3,t4
beq a2,t4,.L55
sext.w a3,a2
blt a2,t4,.L94
.L55:
slli a7,a7,2
addi a2,a7,64
add a2,a2,sp
sw a3,-64(a2)
addi a2,a4,10
ble a1,a2,.L7
addi t1,t1,64
add t1,t1,sp
lw t3,-64(t1)
lw t4,40(a6)
addw t4,t3,t4
mv t1,t4
beq a3,t4,.L57
sext.w t1,a3
blt a3,t4,.L95
.L57:
slli a2,a2,2
addi a3,a2,64
add a3,a3,sp
sw t1,-64(a3)
addi a3,a4,11
ble a1,a3,.L7
addi a7,a7,64
add a7,a7,sp
lw t3,-64(a7)
lw t4,44(a6)
addw t4,t3,t4
mv a7,t4
beq t1,t4,.L59
sext.w a7,t1
bge t1,t4,.L59
sext.w a7,t4
.L59:
slli a3,a3,2
addi t1,a3,64
add t1,t1,sp
sw a7,-64(t1)
addi t1,a4,12
ble a1,t1,.L7
addi a2,a2,64
add a2,a2,sp
lw t3,48(a6)
lw a6,-64(a2)
addw t3,a6,t3
mv a2,t3
beq a7,t3,.L61
sext.w a2,a7
bge a7,t3,.L61
sext.w a2,t3
.L61:
slli a6,t1,2
addi a6,a6,64
add a6,a6,sp
sw a2,-64(a6)
addi a4,a4,13
ble a1,a4,.L7
addi a3,a3,64
add a3,a3,sp
lw a1,-64(a3)
lw a3,60(a0)
addw a1,a3,a1
mv a3,a1
beq a1,a2,.L63
bge a1,a2,.L64
mv a3,a2
.L64:
sext.w a2,a3
.L63:
slli a4,a4,2
addi a4,a4,64
add a4,a4,sp
sw a2,-64(a4)
.L7:
slli a5,a5,2
addi a5,a5,64
add a5,a5,sp
lw a0,-64(a5)
addi sp,sp,64
jr ra
.L76:
mv a5,a4
j .L6
.L79:
sext.w a4,a7
sw a4,12(sp)
li a6,5
bgt a2,a6,.L96
.L66:
li a4,4
j .L8
.L78:
sext.w a3,a7
j .L9
.L81:
sext.w a4,a7
sw a4,20(sp)
li a6,7
bgt a2,a6,.L97
.L67:
li a4,6
j .L8
.L80:
sext.w a3,a7
j .L13
.L83:
sext.w a4,a7
j .L23
.L82:
sext.w a3,a7
j .L21
.L85:
sext.w a4,a7
j .L27
.L84:
sext.w a3,a7
j .L25
.L87:
sext.w a4,a7
j .L31
.L86:
sext.w a3,a7
j .L29
.L88:
mv a3,a4
j .L34
.L89:
sext.w a4,a2
j .L35
.L68:
li a4,8
j .L8
.L77:
addiw a5,a1,-1
slli a5,a5,2
addi a5,a5,64
add a5,a5,sp
lw a0,-64(a5)
addi sp,sp,64
jr ra
.L65:
li a4,2
j .L8
.L69:
li a4,10
j .L8
.L70:
li a4,12
j .L8
.L71:
li a4,14
j .L8
.L90:
sext.w a3,t4
j .L47
.L91:
sext.w t1,t4
j .L49
.L92:
sext.w a7,t4
j .L51
.L93:
sext.w a2,t4
j .L53
.L94:
sext.w a3,t4
j .L55
.L95:
sext.w t1,t4
j .L57
.size max_sum_nonadjacent, .-max_sum_nonadjacent
.align 1
.globl longest_common_subseq
.type longest_common_subseq, @function
longest_common_subseq:
addi sp,sp,-1072
mv a5,sp
sd s0,1056(sp)
sd s1,1048(sp)
sd s3,1032(sp)
mv s1,a1
mv s0,a0
mv s3,a2
li a1,0
li a2,1024
mv a0,a5
sd s2,1040(sp)
sd ra,1064(sp)
mv s2,a3
call memset@plt
ble s1,zero,.L99
ble s2,zero,.L99
addiw a1,s1,-1
addiw t5,s2,-1
slli a4,a1,32
srli a1,a4,26
slli a4,t5,32
srli t5,a4,30
addi a5,sp,64
addi a4,s3,4
mv t6,s0
add a1,a1,a5
add t5,t5,a4
.L100:
lw t4,0(t6)
addi a6,a0,68
mv a7,a0
mv a4,s3
.L105:
lw a5,0(a4)
beq a5,t4,.L108
lw a5,-4(a6)
lw t1,4(a7)
beq t1,a5,.L102
mv t3,t1
bge t1,a5,.L104
mv t3,a5
.L104:
sext.w a5,t3
.L102:
sw a5,0(a6)
addi a4,a4,4
addi a7,a7,4
addi a6,a6,4
bne a4,t5,.L105
addi a0,a0,64
addi t6,t6,4
bne a0,a1,.L100
.L99:
slli a5,s1,4
add a5,a5,s2
ld ra,1064(sp)
ld s0,1056(sp)
slli a5,a5,2
addi a5,a5,1024
add a5,a5,sp
lw a0,-1024(a5)
ld s1,1048(sp)
ld s2,1040(sp)
ld s3,1032(sp)
addi sp,sp,1072
jr ra
.L108:
lw a5,0(a7)
addiw a5,a5,1
j .L102
.size longest_common_subseq, .-longest_common_subseq
.section .text.startup,"ax",@progbits
.align 1
.globl main
.type main, @function
main:
addi sp,sp,-160
lla a5,.LANCHOR0
ld t2,16(a5)
ld t0,24(a5)
ld t6,32(a5)
ld t5,40(a5)
ld t4,48(a5)
lw t3,56(a5)
ld t1,64(a5)
ld a7,72(a5)
ld a6,80(a5)
ld a4,104(a5)
ld a2,88(a5)
ld a3,96(a5)
sd ra,152(sp)
sd s1,136(sp)
ld ra,8(a5)
ld s1,0(a5)
lw a5,112(a5)
sd s0,144(sp)
addi s0,sp,64
sd ra,72(sp)
sd t2,80(sp)
sd t0,88(sp)
sd t6,96(sp)
sd t5,104(sp)
sd t4,112(sp)
sw t3,120(sp)
sd t1,8(sp)
sd a7,16(sp)
sd a6,24(sp)
sd a4,48(sp)
sd a2,32(sp)
sd a3,40(sp)
li a1,15
sd s1,64(sp)
mv a0,s0
sw a5,56(sp)
call max_sum_nonadjacent
call putint@plt
li a0,10
call putch@plt
addi a2,sp,8
li a3,13
li a1,15
mv a0,s0
call longest_common_subseq
call putint@plt
li a0,10
call putch@plt
ld ra,152(sp)
ld s0,144(sp)
ld s1,136(sp)
li a0,0
addi sp,sp,160
jr ra
.size main, .-main
.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
.section .rodata
.align 3
.set .LANCHOR0,. + 0
.LC0:
.word 8
.word 7
.word 4
.word 1
.word 2
.word 7
.word 0
.word 1
.word 9
.word 3
.word 4
.word 8
.word 3
.word 7
.word 0
.zero 4
.LC1:
.word 3
.word 9
.word 7
.word 1
.word 4
.word 2
.word 4
.word 3
.word 6
.word 8
.word 0
.word 1
.word 5
.bss
.align 3
.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