论坛元老
- 积分
- 3337
- 金钱
- 3337
- 注册时间
- 2013-5-28
- 在线时间
- 467 小时
|
10金钱
请教下各位,KEIL5如何在C中内嵌汇编?
网上找了半天也不能正常使用
在"xx.c"中加入汇编代码
#pragma ASM
;Assembler Code Here
#pragma ENDASM
__asm ("ADD R0, %[input_i], %[input_j]" : /* This is an empty output operand list */ : [input_i] "r" (i), [input_j] "r" (j) : "r5","r6","cc","memory" /*Use "r5" instead of "R5" */ );
asm(
"TST LR, #0x40\n\t"
"BEQ from_nonsecure\n\t"
"from_secure:\n\t"
"TST LR, #0x04\n\t"
"ITE EQ\n\t"
"MRSEQ R0, MSP\n\t"
"MRSNE R0, PSP\n\t"
"B hard_fault_handler_c\n\t"
"from_nonsecure:\n\t"
"MRS R0, CONTROL_NS\n\t"
"TST R0, #2\n\t"
"ITE EQ\n\t"
"MRSEQ R0, MSP_NS\n\t"
"MRSNE R0, PSP_NS\n\t"
"B hard_fault_handler_c\n\t"
);
这几个都提示R0 或者LR或者ADD MOV没有定义什么的.
|
|