【发布时间】:2021-06-01 01:13:05
【问题描述】:
这是C程序(包括内联汇编)中的一个函数,用gcc编译并运行正常。
- 变量声明末尾的 asm 语句是什么?
- 为什么在函数内部声明外部变量?与在函数外声明相比有什么效果?
extern unsigned char __heap_base; extern unsigned char __heap_limit; caddr_t _sbrk_r (struct _reent *r,int incr) { extern unsigned char __bottom_of_heap asm ("__heap_base"); extern unsigned char __limit_of_heap asm ("__heap_limit"); register unsigned char *__stack_ptr asm ("sp"); ... }
在另一个汇编文件中,__heap_base、__heap_limit 定义如下(摘录)。
.global __heap_base
.global __heap_limit
__user_thread_space:
.equ __heap_base, __user_thread_space + THREAD_AREA
.equ __heap_limit, __heap_base + HEAP_SIZE
【问题讨论】:
-
你从哪里得到这个代码?
-
它来自我的同事,我认为它是 arm 为启动代码提供的。
标签: c gcc inline-assembly