【发布时间】:2016-08-17 13:22:20
【问题描述】:
我正在尝试从 Compiler RT 获取数学例程,并使用 GCC 工具链用于 ARM Cortex M3/M4F 处理器(带有 fpu 的 armv7m 和 armv7em)。
除了以下函数中的两行代码(msr CPSR_f, ip 和 msr CPSR_f, #APSR_C)之外,我已经编译了所有内容(只需进行少量更改)
#define APSR_Z (1 << 30)
#define APSR_C (1 << 29)
DEFINE_COMPILERRT_FUNCTION(__aeabi_cfcmple)
// Per the RTABI, this function must preserve r0-r11.
// Save lr in the same instruction for compactness
push {r0-r3, lr}
bl __aeabi_fcmplt
cmp r0, #1
IT(eq)
moveq ip, #0
beq 1f
ldm sp, {r0-r3}
bl __aeabi_fcmpeq
cmp r0, #1
IT(eq)
moveq ip, #(APSR_C | APSR_Z)
IT(ne)
movne ip, #(APSR_C)
1:
msr CPSR_f, ip
pop {r0-r3}
POP_PC()
END_COMPILERRT_FUNCTION(__aeabi_cfcmple)
还有其他功能:
DEFINE_COMPILERRT_FUNCTION(__aeabi_cfcmpeq)
push {r0-r3, lr}
bl __aeabi_cfcmpeq_check_nan
cmp r0, #1
pop {r0-r3, lr}
// NaN has been ruled out, so __aeabi_cfcmple can't trap
bne __aeabi_cfcmple
msr CPSR_f, #APSR_C
JMP(lr)
END_COMPILERRT_FUNCTION(__aeabi_cfcmpeq)
CPSR_f 表示法在 armv7m 指令集上不可用。如何将msr CPSR_f, ip 和msr CPSR_f, #APSR_C 转换为armv7m 代码(armv7em 应该相同)?
【问题讨论】:
标签: gcc assembly arm cortex-m3 libgcc