我希望将 AN78175 的安全软件程序库集成到我正在开发的 PSoC5LP 项目中,该项目需要对 RAM/闪存/CPU 进行更密集的自测试。 我的问题是在尝试组装 SelfTest_CPU_s.s 时出现的。 装配源文件。 出于某种原因,它似乎无法识别表示注释的分号字符?
以下是该文件的完整内容:
;-------------------------------------------------------------------------------; FILENAME: SelfTest_CPU.s; Version 1.0;; DESCRIP
tiON:; Assembly routines for RealView compiler.;;-------------------------------------------------------------------------------; Copyright 2010-2012, Cypress Semiconductor Corporation. All rights reserved.; You may use this file only in accordance with the license, terms, conditions, ; disclaimers, and limitations in the end user license agreement accompanying ; the software package with which this file was provided.;------------------------------------------------------------------------------- AREA |.text|,CODE THUMB;-------------------------------------------------------------------------------; Function Name: CPU_PSoC_5_Asm;-------------------------------------------------------------------------------; Summary:; Tests all ARM M3 CPU registers except PC.;; Parameters:; None;; Return:; void.;;-------------------------------------------------------------------------------; void CPU_PSoC_5_Asm(void)CPU_PSoC_5_Asm FUNCTION EXPORT CPU_PSoC_5_Asm PUSH {R1-R12, LR} MOV R0, #0xAAAAAAAA CMP R0, #0xAAAAAAAA BNE.W test_asm_fail MOV R0, #0x55555555 CMP R0, #0x55555555 BNE.W test_asm_fail MOV R1, #0xAAAAAAAA CMP R1, #0xAAAAAAAA BNE.W test_asm_fail MOV R1, #0x55555555 CMP R1, #0x55555555 BNE.W test_asm_fail MOV R2, #0xAAAAAAAA CMP R2, #0xAAAAAAAA BNE.W test_asm_fail MOV R2, #0x55555555 CMP R2, #0x55555555 BNE.W test_asm_fail MOV R3, #0xAAAAAAAA CMP R3, #0xAAAAAAAA BNE test_asm_fail MOV R3, #0x55555555 CMP R3, #0x55555555 BNE test_asm_fail MOV R4, #0xAAAAAAAA CMP R4, #0xAAAAAAAA BNE test_asm_fail MOV R4, #0x55555555 CMP R4, #0x55555555 BNE test_asm_fail MOV R5, #0xAAAAAAAA CMP R5, #0xAAAAAAAA BNE test_asm_fail MOV R5, #0x55555555 CMP R5, #0x55555555 BNE test_asm_fail MOV R6, #0xAAAAAAAA CMP R6, #0xAAAAAAAA BNE test_asm_fail MOV R6, #0x55555555 CMP R6, #0x55555555 BNE test_asm_fail MOV R7, #0xAAAAAAAA CMP R7, #0xAAAAAAAA BNE test_asm_fail MOV R7, #0x55555555 CMP R7, #0x55555555 BNE test_asm_fail MOV R8, #0xAAAAAAAA CMP R8, #0xAAAAAAAA BNE test_asm_fail MOV R8, #0x55555555 CMP R8, #0x55555555 BNE test_asm_fail MOV R9, #0xAAAAAAAA CMP R9, #0xAAAAAAAA BNE test_asm_fail MOV R9, #0x55555555 CMP R9, #0x55555555 BNE test_asm_fail MOV R10, #0xAAAAAAAA CMP R10, #0xAAAAAAAA BNE test_asm_fail MOV R10, #0x55555555 CMP R10, #0x55555555 BNE test_asm_fail MOV R11, #0xAAAAAAAA CMP R11, #0xAAAAAAAA BNE test_asm_fail MOV R11, #0x55555555 CMP R11, #0x55555555 BNE test_asm_fail MOV R12, #0xAAAAAAAA CMP R12, #0xAAAAAAAA BNE test_asm_fail MOV R12, #0x55555555 CMP R12, #0x55555555 BNE test_asm_fail MOV LR, #0xAAAAAAAA CMP LR, #0xAAAAAAAA BNE test_asm_fail MOV LR, #0x55555555 CMP LR, #0x55555555 BNE test_asm_fail ; Test SP register ; Note: SP ignores writes to the lower two bits, ; so they are intentionally set to 0 ; Save SP to R0 MOV R0, SP ; Load SP with 0xAAAAAAA8 LDR R1, =0xAAAAAAA8 MOV SP, R1 CMP SP, R1 ; Restore SP and return failure IT NE MOVNE SP, R0 BNE test_asm_fail ; Load SP with #0x55555554 LDR R1, =0x55555554 MOV SP, R1 CMP SP, R1 IT NE MOVNE SP, R0 BNE test_asm_fail MOV SP, R0 ; Return success MOV R0, #0 POP {R1-R12, LR} BX LR ; Return failure test_asm_fail MOV R0, #0x00000001 POP {R1-R12, LR} BX LR ENDFUNC END;[] END OF FILE
我知道这个代码已经很旧了(好像是 2012 年的)。 是否存在某些不兼容性? 我注意到它在顶部注释块中提到了"RealView Compiler" 。 这可能是某个不再使用的传统编译器/汇编器吗? 无论如何,ARM GNU GCC 是否不将分号视为注释? 我是否应该删除这个源文件,然后使用写在 SelfTest_CPU_asm.c 中的 CPU_PSoC_Asm() 函数? 文件? 我相信,它所做的事情本质上是一样的:
__attribute__((naked)) uint8 CPU_PSoC_Asm(void) /* declaration of function if PSoC 5 GCC compiler */ { /* Disable global interrupts */ CyGlobalIntDisable; __ASM volatile ( " PUSH {R1-R12, LR} nt" CPU_REGISTER_TEST("R0") #if (ERROR_IN_CPU_REGISTERS) CPU_REGISTER_TEST_ERROR("R1") #else CPU_REGISTER_TEST("R1") #endif CPU_REGISTER_TEST("R2") CPU_REGISTER_TEST("R3") CPU_REGISTER_TEST("R4") CPU_REGISTER_TEST("R5") CPU_REGISTER_TEST("R6") CPU_REGISTER_TEST("R7") CPU_REGISTER_TEST("R8") CPU_REGISTER_TEST("R9") CPU_REGISTER_TEST("R10") CPU_REGISTER_TEST("R11") CPU_REGISTER_TEST("R12") CPU_REGISTER_TEST("LR") /* Test SP register */ /* Note: SP ignores writes to the lower two bits, so they are intentionally set to 0 */ /* Save SP to R0 */ " MOV R0, SP nt" /* Load SP with 0xAAAAAAA8 */ " LDR R1, =0xAAAAAAA8 nt" " MOV SP, R1 nt" " CMP SP, R1 nt" /* Restore SP and return failure */ " IT NE nt" " MOVNE SP, R0 nt" " BNE __test_asm_fail nt" /* Load SP with 0x55555554 */ " LDR R1, =0x55555554 nt" " MOV SP, R1 nt" " CMP SP, R1 nt" " IT NE nt" " MOVNE SP, R0 nt" " BNE __test_asm_fail nt" " MOV SP, R0 nt" /* Return success */ " MOV R0, #0 nt" " POP {R1-R12, LR} nt" " BX LR nt" /* Return failure */ "__test_asm_fail: nt" " MOV R0, 0x00000001 nt" " POP {R1-R12, LR} nt" " BX LR nt"); /* Enable global interrupts */ CyGlobalIntEnable; /* end of assembler code for PSoC 5 */ }
我注意到 CyGlobalIntDisable/CyGlobalIntEnable 也会出错:",不支持裸函数中的非 ASM 语句" 。 是否可以分别用" CPSID i nt" 和" CPSIE i nt" 来代替?
我使用的是 PSoC Creator 4.3,编译器是 ARM GCC 5.4-2016-q2-update。