forked from NUDT-compiler/nudt-compiler-cpp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
293 lines
4.6 KiB
293 lines
4.6 KiB
.data
|
|
.globl i
|
|
.p2align 2
|
|
i:
|
|
.zero 4
|
|
.globl k
|
|
.p2align 2
|
|
k:
|
|
.zero 4
|
|
|
|
.text
|
|
.globl inc_impl
|
|
.p2align 2
|
|
inc_impl:
|
|
.L.inc_impl.0:
|
|
stp x29, x30, [sp, #-16]!
|
|
mov x29, sp
|
|
mov x8, x0
|
|
mov w9, w1
|
|
mov w10, #0
|
|
cmp w9, w10
|
|
b.eq .L.inc_impl.1
|
|
b .L.inc_impl.2
|
|
.L.inc_impl.1:
|
|
ldr w9, [x8]
|
|
mov w10, #1
|
|
add w9, w9, w10
|
|
str w9, [x8]
|
|
b .L.inc_impl.3
|
|
.L.inc_impl.2:
|
|
ldr w10, [x8]
|
|
mov w11, #2
|
|
lsl w10, w10, #1
|
|
str w10, [x8]
|
|
mov w10, #1
|
|
sub w9, w9, w10
|
|
mov x0, x8
|
|
mov w1, w9
|
|
bl inc_impl
|
|
b .L.inc_impl.3
|
|
.L.inc_impl.3:
|
|
ldp x29, x30, [sp], #16
|
|
ret
|
|
|
|
.text
|
|
.globl inc
|
|
.p2align 2
|
|
inc:
|
|
.L.inc.0:
|
|
stp x29, x30, [sp, #-16]!
|
|
mov x29, sp
|
|
mov x8, x0
|
|
adrp x9, k
|
|
add x9, x9, :lo12:k
|
|
ldr w9, [x9]
|
|
mov x0, x8
|
|
mov w1, w9
|
|
bl inc_impl
|
|
ldp x29, x30, [sp], #16
|
|
ret
|
|
|
|
.text
|
|
.globl add_impl
|
|
.p2align 2
|
|
add_impl:
|
|
.L.add_impl.0:
|
|
stp x29, x30, [sp, #-16]!
|
|
mov x29, sp
|
|
mov x8, x0
|
|
mov x9, x1
|
|
mov w10, w2
|
|
mov w11, #0
|
|
cmp w10, w11
|
|
b.eq .L.add_impl.1
|
|
b .L.add_impl.2
|
|
.L.add_impl.1:
|
|
ldr w10, [x8]
|
|
ldr w9, [x9]
|
|
add w9, w10, w9
|
|
str w9, [x8]
|
|
b .L.add_impl.3
|
|
.L.add_impl.2:
|
|
ldr w11, [x8]
|
|
mov w12, #2
|
|
lsl w11, w11, #1
|
|
str w11, [x8]
|
|
mov w11, #1
|
|
sub w10, w10, w11
|
|
mov x0, x8
|
|
mov x1, x9
|
|
mov w2, w10
|
|
bl add_impl
|
|
b .L.add_impl.3
|
|
.L.add_impl.3:
|
|
ldp x29, x30, [sp], #16
|
|
ret
|
|
|
|
.text
|
|
.globl add
|
|
.p2align 2
|
|
add:
|
|
.L.add.0:
|
|
stp x29, x30, [sp, #-16]!
|
|
mov x29, sp
|
|
mov x8, x0
|
|
mov x9, x1
|
|
adrp x10, k
|
|
add x10, x10, :lo12:k
|
|
ldr w10, [x10]
|
|
mov x0, x8
|
|
mov x1, x9
|
|
mov w2, w10
|
|
bl add_impl
|
|
ldp x29, x30, [sp], #16
|
|
ret
|
|
|
|
.text
|
|
.globl sub_impl
|
|
.p2align 2
|
|
sub_impl:
|
|
.L.sub_impl.0:
|
|
stp x29, x30, [sp, #-16]!
|
|
mov x29, sp
|
|
mov x8, x0
|
|
mov x9, x1
|
|
mov w10, w2
|
|
mov w11, #0
|
|
cmp w10, w11
|
|
b.eq .L.sub_impl.1
|
|
b .L.sub_impl.2
|
|
.L.sub_impl.1:
|
|
ldr w10, [x8]
|
|
ldr w9, [x9]
|
|
sub w9, w10, w9
|
|
str w9, [x8]
|
|
b .L.sub_impl.3
|
|
.L.sub_impl.2:
|
|
ldr w11, [x8]
|
|
mov w12, #2
|
|
lsl w11, w11, #1
|
|
str w11, [x8]
|
|
mov w11, #1
|
|
sub w10, w10, w11
|
|
mov x0, x8
|
|
mov x1, x9
|
|
mov w2, w10
|
|
bl sub_impl
|
|
b .L.sub_impl.3
|
|
.L.sub_impl.3:
|
|
ldp x29, x30, [sp], #16
|
|
ret
|
|
|
|
.text
|
|
.globl sub
|
|
.p2align 2
|
|
sub:
|
|
.L.sub.0:
|
|
stp x29, x30, [sp, #-16]!
|
|
mov x29, sp
|
|
mov x8, x0
|
|
mov x9, x1
|
|
adrp x10, k
|
|
add x10, x10, :lo12:k
|
|
ldr w10, [x10]
|
|
mov x0, x8
|
|
mov x1, x9
|
|
mov w2, w10
|
|
bl sub_impl
|
|
ldp x29, x30, [sp], #16
|
|
ret
|
|
|
|
.text
|
|
.globl main
|
|
.p2align 2
|
|
main:
|
|
.L.main.0:
|
|
stp x29, x30, [sp, #-16]!
|
|
mov x29, sp
|
|
sub sp, sp, #64
|
|
str x20, [sp, #0]
|
|
str x19, [sp, #8]
|
|
str x21, [sp, #16]
|
|
mov x19, x29
|
|
sub x19, x19, #16
|
|
mov w8, #-1
|
|
str w8, [x19]
|
|
mov x8, #4
|
|
add x8, x19, x8
|
|
mov w9, #0
|
|
str w9, [x8]
|
|
bl getint
|
|
mov w9, w0
|
|
adrp x8, k
|
|
add x8, x8, :lo12:k
|
|
str w9, [x8]
|
|
bl getint
|
|
mov w8, w0
|
|
mov x9, x29
|
|
sub x9, x9, #8
|
|
str w8, [x9]
|
|
mov x0, x19
|
|
bl getarray
|
|
mov w8, w0
|
|
b .L.main.1
|
|
.L.main.1:
|
|
mov x8, x29
|
|
sub x8, x8, #8
|
|
ldr w8, [x8]
|
|
mov w9, #0
|
|
cmp w8, w9
|
|
b.ne .L.main.2
|
|
b .L.main.3
|
|
.L.main.2:
|
|
mov x8, x29
|
|
sub x8, x8, #16
|
|
ldr w8, [x8]
|
|
mov x9, x29
|
|
sub x9, x9, #4
|
|
str w8, [x9]
|
|
b .L.main.4
|
|
.L.main.3:
|
|
mov w8, #10
|
|
mov w0, w8
|
|
bl putch
|
|
mov w8, #0
|
|
mov w0, w8
|
|
ldr x20, [sp, #0]
|
|
ldr x19, [sp, #8]
|
|
ldr x21, [sp, #16]
|
|
add sp, sp, #64
|
|
ldp x29, x30, [sp], #16
|
|
ret
|
|
.L.main.4:
|
|
mov x8, x29
|
|
sub x8, x8, #4
|
|
ldr w8, [x8]
|
|
mov w9, #5
|
|
cmp w8, w9
|
|
b.lt .L.main.5
|
|
b .L.main.6
|
|
.L.main.5:
|
|
adrp x8, i
|
|
add x8, x8, :lo12:i
|
|
ldr w8, [x8]
|
|
mov w0, w8
|
|
bl putint
|
|
mov x21, x29
|
|
sub x21, x21, #4
|
|
ldr w8, [x21]
|
|
mov w0, w8
|
|
bl putint
|
|
mov x20, x29
|
|
sub x20, x20, #8
|
|
ldr w8, [x20]
|
|
mov w0, w8
|
|
bl putint
|
|
mov x19, x29
|
|
sub x19, x19, #16
|
|
ldr w8, [x19]
|
|
mov w0, w8
|
|
bl putint
|
|
mov x0, x19
|
|
mov x1, x20
|
|
bl add
|
|
mov x0, x21
|
|
mov x1, x20
|
|
bl add
|
|
mov x0, x19
|
|
mov x1, x20
|
|
bl sub
|
|
b .L.main.4
|
|
.L.main.6:
|
|
adrp x19, i
|
|
add x19, x19, :lo12:i
|
|
mov x0, x19
|
|
bl inc
|
|
mov x0, x19
|
|
mov x20, x29
|
|
sub x20, x20, #16
|
|
mov x1, x20
|
|
bl add
|
|
ldr w8, [x19]
|
|
mov x9, #4
|
|
add x9, x20, x9
|
|
ldr w9, [x9]
|
|
cmp w8, w9
|
|
b.eq .L.main.7
|
|
b .L.main.8
|
|
.L.main.7:
|
|
b .L.main.3
|
|
.L.main.8:
|
|
b .L.main.1
|