当前位置:网站首页>The problem of formatting IAR sprintf floating point to 0.0 in UCOS assembly
The problem of formatting IAR sprintf floating point to 0.0 in UCOS assembly
2022-07-26 10:42:00 【aping_ cs_ dn】
Reference from http://blog.chinaunix.net/uid-21977330-id-3209252.html
1. Problem description :
When using uocs printf(),sprintf() Printing floating-point numbers will cause problems , But there will be no problem with bare metal
I use it now LPC1758 run UCOS, In the use of sprintf Print float When it's time , No matter what the value is, it will end up 0.0, But the type is int,short There is no problem with type . It is the task stack found on the Internet 8 Byte alignment is OK .
When there is no operating system , The system stack is 8 Byte Alignment , But when used ucos when , User tasks are not necessarily 8 Byte alignment .

Task 3 Stack start pointer in 0x1000000F4, No 8 Byte alignment , So, but in Task 3 Call... In the task printf Wait for a series of functions to have problems .
2. resolvent
I use it IAR, adopt #pragma data_alignment Specify the number of aligned bytes
#pragma data_alignment=8 // If not 8 Byte alignment ,sprintf Floating point numbers of will be output 0.0
static OS_STK App_TaskWorkModeCntStk[APP_CFG_TASK_WORKMODE_CNT_STK_SIZE];
OS_STK T_Stk[Task1_LED1_Stk_Size];
3. 8 Byte alignment reason
The history of this is ARM It does not support non aligned data access ; So there is 64Bit After the data operation instruction of , Directive requirements 8 Byte alignment . , in turn, , After a certain version of the compiler (RVCT3?),AAPCS Just ask for stack 8 Byte alignment .
Yes, first 8 Byte Alignment AAPCS, And then there was CM3. Pay attention to the order .CM3 r2p0 Before , Automatic stack pressing is not required 8 alignment ,r2p0 It seems to be forced alignment .
printf Of 8 Alignment is C Required by the runtime , It's not about hardware ,C RTL The manual is written , You can read . Its roots lie in AAPCS requirement ; and AAPCS The root lies in LDRD Such instructions .
In other words, , In the future, if 128Bit Data operation has ,ARM It doesn't support non - , that AAPCS It may be upgraded to 16 Byte alignment .
For reference ,CM3 and C-RTL The question of alignment .
Thank you, blogger enzo26 Of ChinaUnix Blog
边栏推荐
猜你喜欢

el-table实现可编辑表格

uniapp使用简单方法signalR(仅用于web调试,无法打包app)

从蚂蚁的觅食过程看团队研发(转载)
![[notes on machine learning] [building a cyclic neural network and its application] deeplearning ai course5 1st week programming(keras)](/img/02/f85da2a2f2524fb034b17ed8d06692.png)
[notes on machine learning] [building a cyclic neural network and its application] deeplearning ai course5 1st week programming(keras)

第8期:云原生—— 大学生职场小白该如何学

.net5wtm (asp.net core) PgSQL unpacking operation

【小程序】onReachBottom 事件为什么不能触发 ?(一秒搞定)

Uniapp uses the simple method signalr (only for web debugging, cannot package apps)

RT-Thread 学习笔记(一)---配置RT-Thread开发环境

RT-Thread 学习笔记(三)---用SCons 构建编译环境
随机推荐
SuperMap IClient for Leaflet 加载高斯克吕格投影三度分带CGCS2000大地坐标系WMTS服务
使用定位实现左中右布局,中间内容自适应
剑指Offer(四十九):把字符串转换成整数
【机器学习小记】【搭建循环神经网络及其应用】deeplearning.ai course5 1st week programming(keras)
抽象工厂及其改进示例
Oracle cannot start tnslistener service cannot start
Write to esp8266 burning brush firmware
文案秘籍七步曲至----文献团队协作管理
RT-Thread 学习笔记(六)--- 开启基于SPI Flash的elmfat文件系统(上)
剑指Offer(五十二):正则化表达式
比较器(Comparable与Comparator接口)
The problem of large fluctuation of hx711 data
超图 影像 如何去除黑边(两种方法)
json_ object_ put: Assertion `jso->_ ref_ count > 0‘ failed. Aborted (core dumped)
[leetcode daily question 2021/2/18] [detailed explanation] minimum number of turns of 995. K continuous bits
20210807#1 C语言程序结构
[machine learning notes] [face recognition] deeplearning ai course4 4th week programming
创建EOS账户 Action
【小程序】onReachBottom 事件为什么不能触发 ?(一秒搞定)
第6期:大学生应该选择哪种主流编程语言