我想调用x264中的arm.S文件,我创建了一个test.S文件,在改文件中定义如下:
#include "asm.S"
.text
function x264_prefetch_ref_arm
sub r2, r2, #1
add r0, r0, #64
and r2, r2, r1
add r0, r0, r2, lsl #3
add r2, r1, r1, lsl #1
pld [r0]
pld [r0, r1]
pld [r0, r1, lsl #1]
add r3, r0, r1, lsl #2
pld [r0, r2]
pld [r3]
pld [r3, r1]
pld [r3, r1, lsl #1]
pld [r3, r2]
bx lr
endfunc
编译的时候报错:
bad instruction `endfunc'
bad instruction `function x264_prefetch_ref_arm'
这个是跟编译器有关系吗?
我用的是的linaro编译器gcc-linaro-arm-linux-gnueabihf-4.9-2014.09。
另外有个疑问,汇编中直接使用#include<>的对吗?不是应该用.include<>吗?
我吧#改成.后,发现编译错误又变成:
bad instruction `elf .hidden EXTERN_ASMx264_prefetch_ref_arm'
bad instruction `elf .size x264_prefetch_ref_arm,.-x264_prefetch_ref_arm'
bad instruction `elf .type EXTERN_ASMx264_prefetch_ref_arm,%function'
bad instruction `func .endfunc'
bad instruction `func .func EXTERN_ASMx264_prefetch_ref_arm'
麻烦帮我解答下,谢谢。
不好意思, 我说的是x264里面的asm.S, 我说成 arm.S了,asm.S全部内容:
#include "config.h"
.syntax unified
#if HAVE_NEON
.arch armv7-a
#elif HAVE_ARMV6T2
.arch armv6t2
#elif HAVE_ARMV6
.arch armv6
#endif
.fpu neon
#ifdef PREFIX
# define EXTERN_ASM _
#else
# define EXTERN_ASM
#ifdef __ELF__
# define ELF
# define ELF @
#if HAVE_AS_FUNC
# define FUNC
# define FUNC @
.macro require8, val=1
ELF .eabi_attribute 24, \val
.endm
.macro preserve8, val=1
ELF .eabi_attribute 25, \val
.macro function name, export=1
.macro endfunc
ELF .size \name, . - \name
FUNC .endfunc
.purgem endfunc
.align 2
.if \export == 1
.global EXTERN_ASM\name
ELF .hidden EXTERN_ASM\name
ELF .type EXTERN_ASM\name, %function
FUNC .func EXTERN_ASM\name
EXTERN_ASM\name:
.else
ELF .hidden \name
ELF .type \name, %function
FUNC .func \name
\name:
.endif
.macro movrel rd, val
#if HAVE_ARMV6T2 && !defined(PIC)
movw \rd, #:lower16:\val
movt \rd, #:upper16:\val
ldr \rd, =\val
.macro movconst rd, val
#if HAVE_ARMV6T2
.if \val >> 16
#define GLUE(a, b) a ## b
#define JOIN(a, b) GLUE(a, b)
#define X(s) JOIN(EXTERN_ASM, s)
#define FENC_STRIDE 16
#define FDEC_STRIDE 32
.macro HORIZ_ADD dest, a, b
.ifnb \b
vadd.u16 \a, \a, \b
vpaddl.u16 \a, \a
vpaddl.u32 \dest, \a
.macro SUMSUB_AB sum, diff, a, b
vadd.s16 \sum, \a, \b
vsub.s16 \diff, \a, \b
.macro SUMSUB_ABCD s1, d1, s2, d2, a, b, c, d
SUMSUB_AB \s1, \d1, \a, \b
SUMSUB_AB \s2, \d2, \c, \d
.macro ABS2 a b
vabs.s16 \a, \a
vabs.s16 \b, \b
// dist = distance in elements (0 for vertical pass, 1/2 for horizontal passes)
// op = sumsub/amax (sum and diff / maximum of absolutes)
// d1/2 = destination registers
// s1/2 = source registers
.macro HADAMARD dist, op, d1, d2, s1, s2
.if \dist == 1
vtrn.16 \s1, \s2
vtrn.32 \s1, \s2
.ifc \op, sumsub
SUMSUB_AB \d1, \d2, \s1, \s2
vabs.s16 \s1, \s1
vabs.s16 \s2, \s2
vmax.s16 \d1, \s1, \s2
.macro TRANSPOSE8x8 r0 r1 r2 r3 r4 r5 r6 r7
vtrn.32 \r0, \r4
vtrn.32 \r1, \r5
vtrn.32 \r2, \r6
vtrn.32 \r3, \r7
vtrn.16 \r0, \r2
vtrn.16 \r1, \r3
vtrn.16 \r4, \r6
vtrn.16 \r5, \r7
vtrn.8 \r0, \r1
vtrn.8 \r2, \r3
vtrn.8 \r4, \r5
vtrn.8 \r6, \r7
.macro TRANSPOSE4x4 r0 r1 r2 r3
.macro TRANSPOSE4x4_16 d0 d1 d2 d3
vtrn.32 \d0, \d2
vtrn.32 \d1, \d3
vtrn.16 \d0, \d1
vtrn.16 \d2, \d3