共2条
1/1 1 跳转至页
require8,preserve8 麻烦板主:require8和preserve8到底怎么回事?
问
实战红书中114页有关ATPCS的要求使用preserve8来保证8位对齐.
我试验了一下,在startup.s中用了这两个指令,不论require8和preserve8都不能保证堆栈为8字节对齐.我的工程C和汇编互相调用,没用这两伪指令程序也正常,到底这两个指令有什么用,我参考了好多资料,得不到合理的解释.谢谢
答 1: 自己做答啦,斑竹忙些啥呢?c和汇编有8位对齐的要求,这两个伪指令可以满足此要求,存在REQUIRE8<——> PRESERVE8的对应关系,但不是说有一个REQUIRE8就要有一个 PRESERVE8,如果是一个c文件和一个汇编文件的调用,也就涉及一个PRESERVE8或者是一个REQUIRE8, 以下剪自ADS1.2中PDF,就很清楚,由此可见,最好不要使用LDRD 或 STRD。
LDRD and STRD instructions (double-word transfers) only work correctly if the address they access is 8-byte aligned.
If your code includes LDRD or STRD transfers to or from the stack, use REQUIRE8 to instruct the linker to ensure that your code is only called from objects that preserve 8-byte alignment of the stack.
If your code preserves 8-byte alignment of the stack, use PRESERVE8 to inform the linker.
The linker ensures that any code that requires 8-byte alignment of the stack is only called, directly or indirectly, by code that preserves 8-byte alignment of the stack.
另外,REQUIRE8和PRESERVE8并不完成8 byte 对齐的操作,对齐由ALIGN完成。
我试验了一下,在startup.s中用了这两个指令,不论require8和preserve8都不能保证堆栈为8字节对齐.我的工程C和汇编互相调用,没用这两伪指令程序也正常,到底这两个指令有什么用,我参考了好多资料,得不到合理的解释.谢谢
答 1: 自己做答啦,斑竹忙些啥呢?c和汇编有8位对齐的要求,这两个伪指令可以满足此要求,存在REQUIRE8<——> PRESERVE8的对应关系,但不是说有一个REQUIRE8就要有一个 PRESERVE8,如果是一个c文件和一个汇编文件的调用,也就涉及一个PRESERVE8或者是一个REQUIRE8, 以下剪自ADS1.2中PDF,就很清楚,由此可见,最好不要使用LDRD 或 STRD。
LDRD and STRD instructions (double-word transfers) only work correctly if the address they access is 8-byte aligned.
If your code includes LDRD or STRD transfers to or from the stack, use REQUIRE8 to instruct the linker to ensure that your code is only called from objects that preserve 8-byte alignment of the stack.
If your code preserves 8-byte alignment of the stack, use PRESERVE8 to inform the linker.
The linker ensures that any code that requires 8-byte alignment of the stack is only called, directly or indirectly, by code that preserves 8-byte alignment of the stack.
另外,REQUIRE8和PRESERVE8并不完成8 byte 对齐的操作,对齐由ALIGN完成。
共2条
1/1 1 跳转至页
回复
我要赚赏金打赏帖 |
|
|---|---|
| 【S32DS】S32K3 RTD7.0.1 HSE 组件配置报错问题解决被打赏¥27元 | |
| 【S32K3XX】MCME 启动 CORE1被打赏¥23元 | |
| AG32VH407下温度大气压传感器及其检测被打赏¥20元 | |
| AG32VH407下光照强度传感器BH1750及其检测被打赏¥22元 | |
| AT32VH407下使用温湿度传感器DHT22进行检测被打赏¥20元 | |
| DIY一个婴儿澡盆温度计被打赏¥34元 | |
| 【FreeRtos】FreeRtos+MPU region 配置规则被打赏¥23元 | |
| 【分享开发笔记,赚取电动螺丝刀】三分钟快速上手驱动墨水屏(ArduinoIDE)被打赏¥28元 | |
| 【S32K3XX】LIN 通讯模块使用被打赏¥31元 | |
| 【FreeRtos】FreeRtos + MPU模块的配置使用被打赏¥32元 | |
我要赚赏金
