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.

335 lines
5.5 KiB

.data
.globl crc32table
.p2align 2
crc32table:
.zero 1024
.globl a
.p2align 2
a:
.zero 400080
.text
.globl _and
.p2align 2
_and:
.L._and.0:
stp x29, x30, [sp, #-16]!
mov x29, sp
sub sp, sp, #48
str x21, [sp, #0]
str x19, [sp, #8]
str x20, [sp, #16]
mov w8, w0
mov w9, w1
mov w19, w9
mov w21, w8
mov w8, #1
mov w12, w8
mov w8, #0
mov w20, w8
mov w8, #32
mov w15, w8
b .L._and.1
.L._and.1:
mov w8, #0
cmp w15, w8
b.ne .L._and.2
b .L._and.3
.L._and.2:
mov w8, #2
add w8, w21, #1
cmp w21, #0
csel w8, w8, w21, lt
asr w8, w8, #1
mov w9, #2
msub w10, w8, w9, w21
add w8, w19, #1
cmp w19, #0
csel w8, w8, w19, lt
asr w9, w8, #1
mov w8, #2
msub w11, w9, w8, w19
add w8, w21, #1
cmp w21, #0
csel w8, w8, w21, lt
asr w21, w8, #1
add w8, w19, #1
cmp w19, #0
csel w8, w8, w19, lt
asr w8, w8, #1
mov w9, #1
cmp w10, w9
b.eq .L._and.6
mov w10, w20
b .L._and.5
.L._and.3:
mov w0, w20
ldr x21, [sp, #0]
ldr x19, [sp, #8]
ldr x20, [sp, #16]
add sp, sp, #48
ldp x29, x30, [sp], #16
ret
.L._and.4:
add w9, w20, w12
mov w10, w9
b .L._and.5
.L._and.5:
mov w9, #2
lsl w9, w12, #1
mov w11, #1
sub w11, w15, w11
mov w19, w8
mov w12, w9
mov w20, w10
mov w15, w11
b .L._and.1
.L._and.6:
mov w9, #1
cmp w11, w9
b.eq .L._and.4
mov w10, w20
b .L._and.5
.text
.globl _xor
.p2align 2
_xor:
.L._xor.0:
stp x29, x30, [sp, #-16]!
mov x29, sp
sub sp, sp, #32
str x20, [sp, #0]
str x19, [sp, #8]
mov w8, w0
mov w9, w1
mov w19, w9
mov w20, w8
mov w8, #1
mov w15, w8
mov w8, #0
mov w9, w8
mov w8, #32
mov w12, w8
b .L._xor.1
.L._xor.1:
mov w8, #0
cmp w12, w8
b.ne .L._xor.2
b .L._xor.3
.L._xor.2:
mov w8, #2
add w8, w20, #1
cmp w20, #0
csel w8, w8, w20, lt
asr w8, w8, #1
mov w10, #2
msub w11, w8, w10, w20
add w8, w19, #1
cmp w19, #0
csel w8, w8, w19, lt
asr w8, w8, #1
mov w10, #2
msub w10, w8, w10, w19
add w8, w20, #1
cmp w20, #0
csel w8, w8, w20, lt
asr w20, w8, #1
add w8, w19, #1
cmp w19, #0
csel w8, w8, w19, lt
asr w8, w8, #1
cmp w11, w10
b.ne .L._xor.4
mov w11, w9
b .L._xor.5
.L._xor.3:
mov w0, w9
ldr x20, [sp, #0]
ldr x19, [sp, #8]
add sp, sp, #32
ldp x29, x30, [sp], #16
ret
.L._xor.4:
add w9, w9, w15
mov w11, w9
b .L._xor.5
.L._xor.5:
mov w9, #2
lsl w9, w15, #1
mov w10, #1
sub w10, w12, w10
mov w19, w8
mov w15, w9
mov w9, w11
mov w12, w10
b .L._xor.1
.text
.globl rotr8
.p2align 2
rotr8:
.L.rotr8.0:
stp x29, x30, [sp, #-16]!
mov x29, sp
mov w8, w0
mov w9, #256
add w9, w8, #255
cmp w8, #0
csel w8, w9, w8, lt
asr w8, w8, #8
mov w0, w8
ldp x29, x30, [sp], #16
ret
.text
.globl crc32
.p2align 2
crc32:
.L.crc32.0:
stp x29, x30, [sp, #-16]!
mov x29, sp
sub sp, sp, #64
str x19, [sp, #0]
str x20, [sp, #8]
str x21, [sp, #16]
str x22, [sp, #24]
str x23, [sp, #32]
mov w8, w0
mov x21, x1
mov w23, w2
mov w22, w8
mov w8, #0
mov w20, w8
b .L.crc32.1
.L.crc32.1:
cmp w20, w23
b.lt .L.crc32.2
b .L.crc32.3
.L.crc32.2:
mov w0, w22
mov w8, #255
mov w1, w8
bl _and
mov w9, w0
sxtw x8, w20
lsl x8, x8, #2
add x8, x21, x8
ldr w8, [x8]
mov w0, w9
mov w1, w8
bl _xor
mov w19, w0
mov w0, w22
bl rotr8
mov w10, w0
adrp x9, crc32table
add x9, x9, :lo12:crc32table
sxtw x8, w19
lsl x8, x8, #2
add x8, x9, x8
ldr w8, [x8]
mov w0, w10
mov w1, w8
bl _xor
mov w9, w0
mov w8, #1
add w8, w20, w8
mov w22, w9
mov w20, w8
b .L.crc32.1
.L.crc32.3:
mov w0, w22
ldr x19, [sp, #0]
ldr x20, [sp, #8]
ldr x21, [sp, #16]
ldr x22, [sp, #24]
ldr x23, [sp, #32]
add sp, sp, #64
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, #32
str x20, [sp, #0]
str x19, [sp, #8]
adrp x8, a
add x8, x8, :lo12:a
mov x0, x8
bl getarray
mov w19, w0
mov w8, #0
mov w11, w8
b .L.main.1
.L.main.1:
mov w8, #256
cmp w11, w8
b.lt .L.main.2
b .L.main.3
.L.main.2:
movz w8, #58769
movk w8, #293, lsl #16
add w10, w8, w11
adrp x9, crc32table
add x9, x9, :lo12:crc32table
sxtw x8, w11
lsl x8, x8, #2
add x8, x9, x8
str w10, [x8]
mov w8, #1
add w8, w11, w8
mov w11, w8
b .L.main.1
.L.main.3:
mov w8, #68
mov w0, w8
bl _sysy_starttime
mov w8, #0
mov w20, w8
b .L.main.4
.L.main.4:
mov w8, #0
cmp w19, w8
b.ne .L.main.5
b .L.main.6
.L.main.5:
mov w8, #0
mov w0, w8
adrp x8, a
add x8, x8, :lo12:a
mov x1, x8
mov w2, w19
bl crc32
mov w9, w0
movz w8, #58769
movk w8, #293, lsl #16
sdiv w14, w9, w8
msub w9, w14, w8, w9
mov w8, #1
sub w8, w19, w8
mov w20, w9
mov w19, w8
b .L.main.4
.L.main.6:
mov w8, #73
mov w0, w8
bl _sysy_stoptime
mov w0, w20
bl putint
mov w8, #10
mov w0, w8
bl putch
mov w8, #0
mov w0, w8
ldr x20, [sp, #0]
ldr x19, [sp, #8]
add sp, sp, #32
ldp x29, x30, [sp], #16
ret