sysy-data/functional_c/asm/66_exgcd.s

158 lines
2.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 "66_exgcd.sy"
.globl exgcd
.p2align 1
.type exgcd,@function
exgcd:
addi sp, sp, -32
sd ra, 24(sp)
sd s0, 16(sp)
sd s1, 8(sp)
sd s2, 0(sp)
mv s0, a3
mv s1, a2
beqz a1, .LBB0_2
divw s2, a0, a1
mulw a2, s2, a1
subw a2, a0, a2
mv a0, a1
mv a1, a2
mv a2, s1
mv a3, s0
call exgcd
lw a1, 0(s0)
lw a2, 0(s1)
sw a1, 0(s1)
lw a1, 0(s0)
mulw a1, a1, s2
subw a1, a2, a1
j .LBB0_3
.LBB0_2:
li a1, 0
li a2, 1
sw a2, 0(s1)
.LBB0_3:
sw a1, 0(s0)
ld ra, 24(sp)
ld s0, 16(sp)
ld s1, 8(sp)
ld s2, 0(sp)
addi sp, sp, 32
ret
.Lfunc_end0:
.size exgcd, .Lfunc_end0-exgcd
.globl main
.p2align 1
.type main,@function
main:
addi sp, sp, -16
sd ra, 8(sp)
li a0, 1
sw a0, 4(sp)
sw a0, 0(sp)
li a0, 7
li a1, 15
addi a2, sp, 4
mv a3, sp
call exgcd
lw a0, 4(sp)
lui a1, 559241
addiw a1, a1, -1911
mul a1, a0, a1
srli a1, a1, 32
addw a1, a1, a0
srliw a2, a1, 31
sraiw a1, a1, 3
addw a1, a1, a2
slliw a2, a1, 4
subw a1, a1, a2
addw a0, a0, a1
addiw a0, a0, 15
andi a1, a0, 255
li a2, 137
mul a1, a1, a2
srli a1, a1, 11
slliw a2, a1, 4
subw a1, a1, a2
addw a0, a0, a1
andi a0, a0, 255
call putint
li a0, 0
ld ra, 8(sp)
addi sp, sp, 16
ret
.Lfunc_end1:
.size main, .Lfunc_end1-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