当前位置:网站首页>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
边栏推荐
- Navicat15 MySQL (centos7) connected to local virtual machine
- C language calculation date interval days
- 在神州IV开发板上成功移植STemWin V5.22
- Constructors, method overloads, object arrays, and static
- 7-25 0-1背包 (50分)
- RT-Thread 学习笔记(八)---开启基于SPI Flash的elmfat文件系统(下)
- 【小程序】onReachBottom 事件为什么不能触发 ?(一秒搞定)
- GIS方法类期刊和论文的综述(Introduction)怎么写?
- 构造器、方法重载、对象数组和static
- json_ object_ put: Assertion `jso->_ ref_ count > 0‘ failed. Aborted (core dumped)
猜你喜欢
![[machine learning notes] [style transfer] deeplearning ai course4 4th week programming(tensorflow2)](/img/94/ff52b043320b6dea5ca1238e314de8.png)
[machine learning notes] [style transfer] deeplearning ai course4 4th week programming(tensorflow2)

第4期:大学生提前职业技能准备之一

Problems encountered in QRcode QR code (C language)
![[leetcode每日一题2021/2/18]【详解】995. K 连续位的最小翻转次数](/img/de/62fca587cde95110c2a967ca93eea5.png)
[leetcode每日一题2021/2/18]【详解】995. K 连续位的最小翻转次数

解决:无法加载文件 C:\Users\user\AppData\Roaming\npm\npx.ps1,因为在此系统上禁止运行脚本 。
![[leetcode daily question 2021/5/8]1723. The shortest time to complete all work](/img/e7/a48bb5b8a86cbc4cd5b37bb16661a8.png)
[leetcode daily question 2021/5/8]1723. The shortest time to complete all work

GIS方法类期刊和论文的综述(Introduction)怎么写?

Anaconda is used on vscode (the environment has been configured)
![[leetcode每日一题2021/8/30]528. 按权重随机选择【中等】](/img/13/c6cb176d7065035f60d55ad20ed1bf.png)
[leetcode每日一题2021/8/30]528. 按权重随机选择【中等】
![Error[Pe147]: declaration is incompatible with '错误问题](/img/4f/57145d78f4dc1fe84d2f271dd9d82f.png)
Error[Pe147]: declaration is incompatible with '错误问题
随机推荐
RT-Thread 学习笔记(七)---开启基于SPI Flash的elmfat文件系统(中)
C language calculation date interval days
在altium designer中禁用USBJATG
[leetcode daily question 2021/4/23]368. Maximum divisible subset
Some web APIs you don't know
uniapp使用简单方法signalR(仅用于web调试,无法打包app)
鹏哥C语言——扫雷2021-08-16
在神州IV开发板上为STemWin 5.22加入触屏驱动
剑指Offer(五):用两个栈实现队列
RT-Thread 学习笔记(五)---编辑、下载、调试程序
Analysis of the transaction problem of chained method call
C language callback function
解决:无法加载文件 C:\Users\user\AppData\Roaming\npm\npx.ps1,因为在此系统上禁止运行脚本 。
Datav beautiful data screen production experience
粽子大战 —— 猜猜谁能赢
sigmod 函数与softmax 函数对比
第7期:内卷和躺平,你怎么选
【小程序】onReachBottom 事件为什么不能触发 ?(一秒搞定)
vscode上使用anaconda(已经配置好环境)
.net operation redis list list