sysy-data/functional_c/asm/68_brainfk.s

357 lines
5.3 KiB
ArmAsm
Raw Normal View History

2024-06-14 13:34:46 +08:00
.text
.attribute 4, 16
.attribute 5, "rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0"
.file "68_brainfk.sy"
.globl read_program
.p2align 1
.type read_program,@function
read_program:
addi sp, sp, -32
sd ra, 24(sp)
sd s0, 16(sp)
sd s1, 8(sp)
sd s2, 0(sp)
call getint
blez a0, .LBB0_4
lui a1, %hi(program)
addi s1, a1, %lo(program)
slli s2, a0, 32
srli s0, s2, 32
.LBB0_2:
call getch
sw a0, 0(s1)
addi s0, s0, -1
addi s1, s1, 4
bnez s0, .LBB0_2
srli a0, s2, 32
j .LBB0_5
.LBB0_4:
li a0, 0
.LBB0_5:
lui a1, %hi(program)
addi a1, a1, %lo(program)
slli a0, a0, 2
add a0, a0, a1
sw zero, 0(a0)
ld ra, 24(sp)
ld s0, 16(sp)
ld s1, 8(sp)
ld s2, 0(sp)
addi sp, sp, 32
ret
.Lfunc_end0:
.size read_program, .Lfunc_end0-read_program
.globl interpret
.p2align 1
.type interpret,@function
interpret:
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)
mv s4, a0
li s1, 0
addi s2, a0, -4
li s3, 50
lui a0, %hi(.LJTI1_0)
addi s7, a0, %lo(.LJTI1_0)
lui s5, %hi(ptr)
lui a0, %hi(tape)
addi s6, a0, %lo(tape)
li s0, 93
li s8, 91
j .LBB1_3
.LBB1_1:
beqz a1, .LBB1_18
.LBB1_2:
addiw s1, s1, 1
.LBB1_3:
slli a0, s1, 2
add a1, s4, a0
lw a1, 0(a1)
addi a2, a1, -43
bltu s3, a2, .LBB1_1
slli a1, a2, 2
add a1, a1, s7
lw a1, 0(a1)
jr a1
.LBB1_5:
lw a0, %lo(ptr)(s5)
slli a0, a0, 2
add a0, a0, s6
lw a1, 0(a0)
addiw a1, a1, 1
sw a1, 0(a0)
addiw s1, s1, 1
j .LBB1_3
.LBB1_6:
call getch
lw a1, %lo(ptr)(s5)
slli a1, a1, 2
add a1, a1, s6
sw a0, 0(a1)
addiw s1, s1, 1
j .LBB1_3
.LBB1_7:
lw a0, %lo(ptr)(s5)
slli a0, a0, 2
add a0, a0, s6
lw a1, 0(a0)
addiw a1, a1, -1
sw a1, 0(a0)
addiw s1, s1, 1
j .LBB1_3
.LBB1_8:
lw a0, %lo(ptr)(s5)
slli a0, a0, 2
add a0, a0, s6
lw a0, 0(a0)
call putch
addiw s1, s1, 1
j .LBB1_3
.LBB1_9:
lw a0, %lo(ptr)(s5)
addiw a0, a0, -1
sw a0, %lo(ptr)(s5)
addiw s1, s1, 1
j .LBB1_3
.LBB1_10:
lw a0, %lo(ptr)(s5)
addiw a0, a0, 1
sw a0, %lo(ptr)(s5)
addiw s1, s1, 1
j .LBB1_3
.LBB1_11:
lw a1, %lo(ptr)(s5)
slli a1, a1, 2
add a1, a1, s6
lw a1, 0(a1)
beqz a1, .LBB1_2
add a0, a0, s2
li a1, 1
j .LBB1_15
.LBB1_13:
addiw a1, a1, 1
.LBB1_14:
addi a0, a0, -4
addi s1, s1, -1
blez a1, .LBB1_2
.LBB1_15:
lw a2, 0(a0)
beq a2, s0, .LBB1_13
bne a2, s8, .LBB1_14
addiw a1, a1, -1
j .LBB1_14
.LBB1_18:
ld ra, 72(sp)
ld s0, 64(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
ret
.Lfunc_end1:
.size interpret, .Lfunc_end1-interpret
.section .rodata,"a",@progbits
.p2align 2
.LJTI1_0:
.word .LBB1_5
.word .LBB1_6
.word .LBB1_7
.word .LBB1_8
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_9
.word .LBB1_2
.word .LBB1_10
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_2
.word .LBB1_11
.text
.globl main
.p2align 1
.type main,@function
main:
addi sp, sp, -32
sd ra, 24(sp)
sd s0, 16(sp)
sd s1, 8(sp)
sd s2, 0(sp)
call getint
blez a0, .LBB2_3
lui a1, %hi(program)
slli a0, a0, 32
srli s2, a0, 32
addi s1, a1, %lo(program)
mv s0, s2
.LBB2_2:
call getch
sw a0, 0(s1)
addi s0, s0, -1
addi s1, s1, 4
bnez s0, .LBB2_2
j .LBB2_4
.LBB2_3:
li s2, 0
.LBB2_4:
lui a0, %hi(program)
addi a0, a0, %lo(program)
slli a1, s2, 2
add a1, a1, a0
sw zero, 0(a1)
call interpret
li a0, 0
ld ra, 24(sp)
ld s0, 16(sp)
ld s1, 8(sp)
ld s2, 0(sp)
addi sp, sp, 32
ret
.Lfunc_end2:
.size main, .Lfunc_end2-main
.type ptr,@object
.section .sbss,"aw",@nobits
.globl ptr
.p2align 2
ptr:
.word 0
.size ptr, 4
.type program,@object
.bss
.globl program
.p2align 2
program:
.zero 131072
.size program, 131072
.type tape,@object
.globl tape
.p2align 2
tape:
.zero 262140
.size tape, 262140
.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
.addrsig_sym program