sysy-data/functional_c/asm/72_hanoi.s

193 lines
2.6 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 "72_hanoi.sy"
.globl move
.p2align 1
.type move,@function
move:
addi sp, sp, -16
sd ra, 8(sp)
sd s0, 0(sp)
mv s0, a1
call putint
li a0, 32
call putch
mv a0, s0
call putint
li a0, 44
call putch
li a0, 32
ld ra, 8(sp)
ld s0, 0(sp)
addi sp, sp, 16
tail putch
.Lfunc_end0:
.size move, .Lfunc_end0-move
.globl hanoi
.p2align 1
.type hanoi,@function
hanoi:
addi sp, sp, -64
sd ra, 56(sp)
sd s0, 48(sp)
sd s1, 40(sp)
sd s2, 32(sp)
sd s3, 24(sp)
sd s4, 16(sp)
sd s5, 8(sp)
li s4, 1
mv s2, a3
mv s3, a1
bne a0, s4, .LBB1_2
mv s5, s3
j .LBB1_4
.LBB1_2:
mv s0, a0
.LBB1_3:
mv s5, a2
addiw s0, s0, -1
sext.w s1, s3
sext.w a3, a2
mv a0, s0
mv a1, s1
mv a2, s2
call hanoi
mv a0, s1
call putint
li a0, 32
call putch
mv a0, s2
call putint
li a0, 44
call putch
li a0, 32
call putch
mv a2, s3
mv s3, s5
bne s0, s4, .LBB1_3
.LBB1_4:
sext.w a0, s5
call putint
li a0, 32
call putch
mv a0, s2
call putint
li a0, 44
call putch
li a0, 32
ld ra, 56(sp)
ld s0, 48(sp)
ld s1, 40(sp)
ld s2, 32(sp)
ld s3, 24(sp)
ld s4, 16(sp)
ld s5, 8(sp)
addi sp, sp, 64
tail putch
.Lfunc_end1:
.size hanoi, .Lfunc_end1-hanoi
.globl main
.p2align 1
.type main,@function
main:
addi sp, sp, -32
sd ra, 24(sp)
sd s0, 16(sp)
sd s1, 8(sp)
call getint
blez a0, .LBB2_3
mv s0, a0
li s1, 1
.LBB2_2:
call getint
li a1, 1
li a2, 2
li a3, 3
call hanoi
li a0, 10
call putch
sext.w a0, s0
addiw s0, s0, -1
bltu s1, a0, .LBB2_2
.LBB2_3:
li a0, 0
ld ra, 24(sp)
ld s0, 16(sp)
ld s1, 8(sp)
addi sp, sp, 32
ret
.Lfunc_end2:
.size main, .Lfunc_end2-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