sysy-data/functional_c/asm/64_calculator.s

894 lines
13 KiB
ArmAsm
Raw Permalink Normal View History

2024-06-14 13:34:46 +08:00
.text
.attribute 4, 16
.attribute 5, "rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0"
.file "64_calculator.sy"
.globl isdigit
.p2align 1
.type isdigit,@function
isdigit:
addiw a0, a0, -48
sltiu a0, a0, 10
ret
.Lfunc_end0:
.size isdigit, .Lfunc_end0-isdigit
.globl power
.p2align 1
.type power,@function
power:
li a2, 1
beqz a1, .LBB1_2
.LBB1_1:
addiw a1, a1, -1
mulw a2, a2, a0
bnez a1, .LBB1_1
.LBB1_2:
mv a0, a2
ret
.Lfunc_end1:
.size power, .Lfunc_end1-power
.globl getstr
.p2align 1
.type getstr,@function
getstr:
addi sp, sp, -48
sd ra, 40(sp)
sd s0, 32(sp)
sd s1, 24(sp)
sd s2, 16(sp)
sd s3, 8(sp)
mv s0, a0
li s1, 0
li s2, 10
li s3, 13
call getch
beq a0, s2, .LBB2_3
.LBB2_1:
beq a0, s3, .LBB2_3
sw a0, 0(s0)
addi s1, s1, 1
addi s0, s0, 4
call getch
bne a0, s2, .LBB2_1
.LBB2_3:
sext.w a0, s1
ld ra, 40(sp)
ld s0, 32(sp)
ld s1, 24(sp)
ld s2, 16(sp)
ld s3, 8(sp)
addi sp, sp, 48
ret
.Lfunc_end2:
.size getstr, .Lfunc_end2-getstr
.globl intpush
.p2align 1
.type intpush,@function
intpush:
lui a1, %hi(intt)
lw a2, %lo(intt)(a1)
addiw a2, a2, 1
sw a2, %lo(intt)(a1)
lui a1, %hi(ints)
addi a1, a1, %lo(ints)
slli a2, a2, 2
add a1, a1, a2
sw a0, 0(a1)
ret
.Lfunc_end3:
.size intpush, .Lfunc_end3-intpush
.globl chapush
.p2align 1
.type chapush,@function
chapush:
lui a1, %hi(chat)
lw a2, %lo(chat)(a1)
addiw a2, a2, 1
sw a2, %lo(chat)(a1)
lui a1, %hi(chas)
addi a1, a1, %lo(chas)
slli a2, a2, 2
add a1, a1, a2
sw a0, 0(a1)
ret
.Lfunc_end4:
.size chapush, .Lfunc_end4-chapush
.globl intpop
.p2align 1
.type intpop,@function
intpop:
lui a1, %hi(intt)
lw a2, %lo(intt)(a1)
lui a0, %hi(ints)
addi a0, a0, %lo(ints)
slli a3, a2, 2
add a0, a0, a3
lw a0, 0(a0)
addiw a2, a2, -1
sw a2, %lo(intt)(a1)
ret
.Lfunc_end5:
.size intpop, .Lfunc_end5-intpop
.globl chapop
.p2align 1
.type chapop,@function
chapop:
lui a1, %hi(chat)
lw a2, %lo(chat)(a1)
lui a0, %hi(chas)
addi a0, a0, %lo(chas)
slli a3, a2, 2
add a0, a0, a3
lw a0, 0(a0)
addiw a2, a2, -1
sw a2, %lo(chat)(a1)
ret
.Lfunc_end6:
.size chapop, .Lfunc_end6-chapop
.globl intadd
.p2align 1
.type intadd,@function
intadd:
lui a1, %hi(intt)
lw a1, %lo(intt)(a1)
lui a2, %hi(ints)
addi a2, a2, %lo(ints)
slli a1, a1, 2
add a1, a1, a2
lw a2, 0(a1)
li a3, 10
mulw a2, a2, a3
addw a0, a0, a2
sw a0, 0(a1)
ret
.Lfunc_end7:
.size intadd, .Lfunc_end7-intadd
.globl find
.p2align 1
.type find,@function
find:
lui a0, %hi(chat)
lw a1, %lo(chat)(a0)
addiw a2, a1, -1
sw a2, %lo(chat)(a0)
lui a0, %hi(chas)
addi a0, a0, %lo(chas)
slli a1, a1, 2
add a0, a0, a1
lw a0, 0(a0)
lui a1, %hi(c)
lui a6, %hi(ii)
lw a4, %lo(ii)(a6)
sw a0, %lo(c)(a1)
lui a1, %hi(get2)
addi a1, a1, %lo(get2)
slli a5, a4, 2
add a5, a5, a1
li a3, 32
sw a3, 0(a5)
addiw a3, a4, 1
slli a3, a3, 2
add a1, a1, a3
sw a0, 0(a1)
addiw a1, a4, 2
snez a0, a2
sw a1, %lo(ii)(a6)
ret
.Lfunc_end8:
.size find, .Lfunc_end8-find
.globl main
.p2align 1
.type main,@function
main:
addi sp, sp, -112
sd ra, 104(sp)
sd s0, 96(sp)
sd s1, 88(sp)
sd s2, 80(sp)
sd s3, 72(sp)
sd s4, 64(sp)
sd s5, 56(sp)
sd s6, 48(sp)
sd s7, 40(sp)
sd s8, 32(sp)
sd s9, 24(sp)
sd s10, 16(sp)
sd s11, 8(sp)
li s2, 0
li s1, 0
lui a0, %hi(intt)
sw zero, %lo(intt)(a0)
lui a0, %hi(chat)
sw zero, %lo(chat)(a0)
lui a0, %hi(get)
addi s0, a0, %lo(get)
li s3, 10
li s4, 13
li a0, 1
slli s5, a0, 32
call getch
beq a0, s3, .LBB9_3
.LBB9_1:
beq a0, s4, .LBB9_3
sw a0, 0(s0)
addi s1, s1, 1
add s2, s2, s5
addi s0, s0, 4
call getch
bne a0, s3, .LBB9_1
.LBB9_3:
lui a0, %hi(i)
lw s5, %lo(i)(a0)
lui a6, %hi(chat)
lw s0, %lo(chat)(a6)
lui a0, %hi(ii)
lw a3, %lo(ii)(a0)
sext.w a0, s1
bge s5, a0, .LBB9_57
srai t1, s2, 32
lui a0, %hi(get)
addi t3, a0, %lo(get)
li a7, 10
lui a0, %hi(get2)
addi t5, a0, %lo(get2)
li s11, 57
lui a0, %hi(.LJTI9_0)
addi t0, a0, %lo(.LJTI9_0)
lui a0, %hi(chas)
addi t4, a0, %lo(chas)
li t2, 37
li s2, 1
lui s10, %hi(c)
li s3, 32
li t6, 40
li s6, 42
li s7, 47
li ra, 45
j .LBB9_7
.LBB9_5:
mv s8, s9
.LBB9_6:
sext.w a0, a3
slli a0, a0, 2
add a0, a0, t5
sw s8, 0(a0)
addi s5, s5, 1
addiw a3, a3, 1
beq s5, t1, .LBB9_56
.LBB9_7:
slli a0, s5, 2
add a0, a0, t3
lw s9, 0(a0)
addiw a0, s9, -48
bltu a0, a7, .LBB9_5
addi a0, s9, -37
li s8, 32
bltu s11, a0, .LBB9_6
slli a0, a0, 2
add a0, a0, t0
lw a0, 0(a0)
slli s4, s2, 57
jr a0
.LBB9_10:
addiw s0, s0, 1
sw s0, %lo(chat)(a6)
slli a0, s0, 2
add a0, a0, t4
sw t6, 0(a0)
j .LBB9_6
.LBB9_11:
sext.w a0, s0
slli a0, a0, 2
add a0, a0, t4
lw a0, 0(a0)
addiw s0, s0, -1
beq a0, t6, .LBB9_14
slli a1, a3, 2
add a1, a1, t5
addi a4, a1, 4
slli a1, s0, 2
add a5, a1, t4
.LBB9_13:
sw s3, -4(a4)
sw a0, 0(a4)
lw a0, 0(a5)
addi a3, a3, 2
addi s0, s0, -1
addi a4, a4, 8
addi a5, a5, -4
bne a0, t6, .LBB9_13
.LBB9_14:
sw s0, %lo(chat)(a6)
sw t6, %lo(c)(s10)
j .LBB9_6
.LBB9_15:
sext.w a0, s0
slliw a1, s0, 1
addw ra, a3, a1
slli a1, a0, 2
add a5, a1, t4
slli a1, a3, 2
add a1, a1, t5
addi s0, a1, 4
.LBB9_16:
lw a4, 0(a5)
addi a2, a4, -37
bltu s11, a2, .LBB9_20
sll a1, s2, a2
addi a2, s4, 1377
and a1, a1, a2
beqz a1, .LBB9_20
addiw a1, a0, -1
addi a0, a0, -1
sw a4, %lo(c)(s10)
sw s3, -4(s0)
sw a4, 0(s0)
addi a3, a3, 2
addi a5, a5, -4
addi s0, s0, 8
bnez a1, .LBB9_16
li a0, 0
mv a3, ra
.LBB9_20:
addiw s0, a0, 1
sw s0, %lo(chat)(a6)
slli a0, s0, 2
add a0, a0, t4
li a1, 43
sw a1, 0(a0)
li a0, 44
li ra, 45
blt a0, s9, .LBB9_23
bne s9, t2, .LBB9_32
j .LBB9_48
.LBB9_22:
addiw s0, s0, 1
sw s0, %lo(chat)(a6)
slli a0, s0, 2
add a0, a0, t4
li a1, 94
sw a1, 0(a0)
j .LBB9_6
.LBB9_23:
beq s9, s7, .LBB9_41
bne s9, ra, .LBB9_6
.LBB9_25:
sext.w a0, a3
sext.w a5, s0
slliw a1, s0, 1
addw a3, a3, a1
slli a1, a5, 2
add s0, a1, t4
slli a1, a0, 2
add a1, a1, t5
addi a4, a1, 4
.LBB9_26:
lw a2, 0(s0)
addi a1, a2, -37
bltu s11, a1, .LBB9_55
sll a1, s2, a1
addi s1, s4, 1377
and a1, a1, s1
beqz a1, .LBB9_55
addiw a1, a5, -1
addi a5, a5, -1
sw a2, %lo(c)(s10)
sw s3, -4(a4)
sw a2, 0(a4)
addi a0, a0, 2
addi s0, s0, -4
addi a4, a4, 8
bnez a1, .LBB9_26
li a5, 0
.LBB9_30:
addiw s0, a5, 1
sw s0, %lo(chat)(a6)
slli a0, s0, 2
add a0, a0, t4
sw ra, 0(a0)
beq s9, t2, .LBB9_48
beq s9, s7, .LBB9_41
.LBB9_32:
bne s9, s6, .LBB9_6
.LBB9_33:
sext.w a0, a3
sext.w a5, s0
slliw a1, s0, 1
addw a3, a3, a1
slli a1, a5, 2
add s0, a1, t4
slli a1, a0, 2
add a1, a1, t5
addi a4, a1, 4
.LBB9_34:
lw a2, 0(s0)
addi a1, a2, -37
bltu s11, a1, .LBB9_38
sll a1, s2, a1
addi s1, s4, 1057
and a1, a1, s1
beqz a1, .LBB9_38
addiw a1, a5, -1
addi a5, a5, -1
sw a2, %lo(c)(s10)
sw s3, -4(a4)
sw a2, 0(a4)
addi a0, a0, 2
addi s0, s0, -4
addi a4, a4, 8
bnez a1, .LBB9_34
li a5, 0
j .LBB9_39
.LBB9_38:
mv a3, a0
.LBB9_39:
addiw s0, a5, 1
sw s0, %lo(chat)(a6)
slli a0, s0, 2
add a0, a0, t4
sw s6, 0(a0)
beq s9, t2, .LBB9_48
bne s9, s7, .LBB9_6
.LBB9_41:
sext.w a0, a3
sext.w a5, s0
slliw a1, s0, 1
addw a3, a3, a1
slli a1, a5, 2
add s0, a1, t4
slli a1, a0, 2
add a1, a1, t5
addi a4, a1, 4
.LBB9_42:
lw a2, 0(s0)
addi a1, a2, -37
bltu s11, a1, .LBB9_46
sll a1, s2, a1
addi s1, s4, 1057
and a1, a1, s1
beqz a1, .LBB9_46
addiw a1, a5, -1
addi a5, a5, -1
sw a2, %lo(c)(s10)
sw s3, -4(a4)
sw a2, 0(a4)
addi a0, a0, 2
addi s0, s0, -4
addi a4, a4, 8
bnez a1, .LBB9_42
li a5, 0
j .LBB9_47
.LBB9_46:
mv a3, a0
.LBB9_47:
addiw s0, a5, 1
sw s0, %lo(chat)(a6)
slli a0, s0, 2
add a0, a0, t4
sw s7, 0(a0)
bne s9, t2, .LBB9_6
.LBB9_48:
sext.w a0, a3
sext.w a5, s0
slliw a1, s0, 1
addw a3, a3, a1
slli a1, a5, 2
add s0, a1, t4
slli a1, a0, 2
add a1, a1, t5
addi a4, a1, 4
.LBB9_49:
lw a2, 0(s0)
addi a1, a2, -37
bltu s11, a1, .LBB9_53
sll a1, s2, a1
addi s1, s4, 1057
and a1, a1, s1
beqz a1, .LBB9_53
addiw a1, a5, -1
addi a5, a5, -1
sw a2, %lo(c)(s10)
sw s3, -4(a4)
sw a2, 0(a4)
addi a0, a0, 2
addi s0, s0, -4
addi a4, a4, 8
bnez a1, .LBB9_49
li a5, 0
j .LBB9_54
.LBB9_53:
mv a3, a0
.LBB9_54:
addiw s0, a5, 1
sw s0, %lo(chat)(a6)
slli a0, s0, 2
add a0, a0, t4
sw t2, 0(a0)
j .LBB9_6
.LBB9_55:
mv a3, a0
j .LBB9_30
.LBB9_56:
lui a0, %hi(ii)
sw a3, %lo(ii)(a0)
.LBB9_57:
sext.w a0, s0
blez a0, .LBB9_61
slli a2, s0, 32
srli a1, a2, 32
slli a0, a3, 2
lui a4, %hi(get2)
addi a4, a4, %lo(get2)
add a0, a0, a4
addi a0, a0, 4
addi a1, a1, 1
lui a4, %hi(chas)
addi a4, a4, %lo(chas)
srli a2, a2, 30
add a2, a2, a4
li a4, 32
li a5, 1
.LBB9_59:
lw s1, 0(a2)
sw a4, -4(a0)
sw s1, 0(a0)
addi a3, a3, 2
addi a0, a0, 8
addi a1, a1, -1
addi a2, a2, -4
bltu a5, a1, .LBB9_59
lui a0, %hi(chat)
sw zero, %lo(chat)(a0)
lui a0, %hi(ii)
sw a3, %lo(ii)(a0)
.LBB9_61:
sext.w a0, a3
lui a1, %hi(get2)
addi s6, a1, %lo(get2)
slli a0, a0, 2
add a0, a0, s6
li a1, 64
sw a1, 0(a0)
lui t5, %hi(intt)
lw a0, %lo(intt)(t5)
li t6, 1
li s2, 62
lui a1, %hi(ints)
addi s8, a1, %lo(ints)
li s5, 32
lui a6, %hi(ii)
li s4, 10
slli a1, t6, 50
addi a1, a1, 11
slli a1, a1, 12
addi s3, a1, -992
li a7, 43
li t0, 45
li t1, 42
li t2, 37
li t3, 94
li t4, 47
li a1, 1
j .LBB9_65
.LBB9_62:
remw a2, a0, s0
.LBB9_63:
sw a3, %lo(intt)(t5)
sw a2, 0(s1)
.LBB9_64:
addiw a1, a1, 1
mv a0, a3
.LBB9_65:
slli s1, a1, 2
add a3, s1, s6
lw a5, 0(a3)
addi a3, a5, -32
bltu s2, a3, .LBB9_82
sll a4, t6, a3
and a4, a4, s3
beqz a4, .LBB9_77
addiw a3, a0, -1
slli a0, a0, 2
add a0, a0, s8
lw s0, 0(a0)
slli a0, a3, 2
add s1, a0, s8
lw a0, 0(s1)
beq a5, a7, .LBB9_71
beq a5, t0, .LBB9_72
.LBB9_69:
beq a5, t1, .LBB9_73
.LBB9_70:
bne a5, t2, .LBB9_74
j .LBB9_62
.LBB9_71:
addw a2, a0, s0
bne a5, t0, .LBB9_69
.LBB9_72:
subw a2, a0, s0
bne a5, t1, .LBB9_70
.LBB9_73:
mulw a2, a0, s0
beq a5, t2, .LBB9_62
.LBB9_74:
beq a5, t3, .LBB9_79
bne a5, t4, .LBB9_63
divw a2, a0, s0
j .LBB9_63
.LBB9_77:
bnez a3, .LBB9_81
mv a3, a0
j .LBB9_64
.LBB9_79:
li a2, 1
beqz s0, .LBB9_63
.LBB9_80:
addiw s0, s0, -1
mulw a2, a2, a0
bnez s0, .LBB9_80
j .LBB9_63
.LBB9_81:
beq a3, s5, .LBB9_87
.LBB9_82:
addiw a5, a5, -48
addiw a3, a0, 1
sw a3, %lo(intt)(t5)
addiw a4, a1, 1
slli a0, a4, 2
add a0, a0, s6
lw s0, 0(a0)
slli a0, a3, 2
add s7, a0, s8
sw a5, 0(s7)
li a0, 1
beq s0, s5, .LBB9_86
add a0, s6, s1
addi s1, a0, 8
li a0, 1
.LBB9_84:
mulw a4, a5, s4
addw a4, a4, s0
lw s0, 0(s1)
addiw a5, a4, -48
addi a0, a0, 1
addi s1, s1, 4
bne s0, s5, .LBB9_84
add a4, a1, a0
sw a5, 0(s7)
.LBB9_86:
sw a0, %lo(ii)(a6)
addiw a1, a4, -1
j .LBB9_64
.LBB9_87:
lui a0, %hi(ints+4)
lw a0, %lo(ints+4)(a0)
lui a2, %hi(i)
sw a1, %lo(i)(a2)
call putint
li a0, 0
ld ra, 104(sp)
ld s0, 96(sp)
ld s1, 88(sp)
ld s2, 80(sp)
ld s3, 72(sp)
ld s4, 64(sp)
ld s5, 56(sp)
ld s6, 48(sp)
ld s7, 40(sp)
ld s8, 32(sp)
ld s9, 24(sp)
ld s10, 16(sp)
ld s11, 8(sp)
addi sp, sp, 112
ret
.Lfunc_end9:
.size main, .Lfunc_end9-main
.section .rodata,"a",@progbits
.p2align 2
.LJTI9_0:
.word .LBB9_48
.word .LBB9_6
.word .LBB9_6
.word .LBB9_10
.word .LBB9_11
.word .LBB9_33
.word .LBB9_15
.word .LBB9_6
.word .LBB9_25
.word .LBB9_6
.word .LBB9_41
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_6
.word .LBB9_22
.type i,@object
.section .sbss,"aw",@nobits
.globl i
.p2align 2
i:
.word 0
.size i, 4
.type ii,@object
.section .sdata,"aw",@progbits
.globl ii
.p2align 2
ii:
.word 1
.size ii, 4
.type intt,@object
.section .sbss,"aw",@nobits
.globl intt
.p2align 2
intt:
.word 0
.size intt, 4
.type ints,@object
.bss
.globl ints
.p2align 2
ints:
.zero 40000
.size ints, 40000
.type chat,@object
.section .sbss,"aw",@nobits
.globl chat
.p2align 2
chat:
.word 0
.size chat, 4
.type chas,@object
.bss
.globl chas
.p2align 2
chas:
.zero 40000
.size chas, 40000
.type c,@object
.section .sbss,"aw",@nobits
.globl c
.p2align 2
c:
.word 0
.size c, 4
.type get2,@object
.bss
.globl get2
.p2align 2
get2:
.zero 40000
.size get2, 40000
.type get,@object
.globl get
.p2align 2
get:
.zero 40000
.size get, 40000
.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