共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 跳转至页
回复
我要赚赏金打赏帖 |
|
|---|---|
| 给28BYJ-48三自由度机械臂加一个网页控制台被打赏¥32元 | |
| 用28BYJ-48电机从零搭一台三自由度机械臂被打赏¥33元 | |
| 【英飞凌开发经验】ModusToolbox配置EdgeTalk外设被打赏¥27元 | |
| 基于BQ76952PFBR的BMS保护板热插拔损坏的原因和处理措施被打赏¥32元 | |
| 三分钟快速上手搭建nRF Connect SDK开发环境(VSCode)被打赏¥25元 | |
| 告别手动建模:我让AI用FreeCAD画了个开发板外壳被打赏¥30元 | |
| 【瑞萨RA8D1测评】总结收官——从IMU动作识别到LVGL桌宠被打赏¥33元 | |
| 【瑞萨BLE/WIFI模块测评】MPU6050双链路对比被打赏¥30元 | |
| 【瑞萨BLE/WIFI模块测评】DA14531被打赏¥28元 | |
| 【瑞萨BLE/WI-FI模块测评】DA16200被打赏¥28元 | |
我要赚赏金
