Fixed-point multiplication (C166 A*B/B)
| I want to multiply two fixed point numbers. After the multiplication I have to shift the result so that the binary point is correct. Example: int a; The multiplication a*b produces a long int value in the MD register. After the shift operation the int result (the lower byte) should be stored in c. |
|
|
Read-Only
Author
Andrew Neil Posted
22-Oct-2003 09:34 GMT Toolset
C166 |
I don't know the '166, but I suspect this is a 'C' issue rather than a processor issue. You could look up the promotion rules in K&R, or you could just try experimenting with casting a, b, and/or the product to long. |
|
Read-Only
Author
Mike Kleshov Posted
22-Oct-2003 09:56 GMT Toolset
C166 |
As Andrew said, this is a C issue. Take your favourite book on C and read about types and expressions. There are a few pitfalls there. - mike |
|
Read-Only
Author
Bruno Büsser Posted
22-Oct-2003 10:45 GMT Toolset
C166 |
That's it! The product a*b is stored as 32 bit value in MD register, then the MD register value is arithmetic shifted right by 10 and the lower 16 bits stored in c. |
http://www.keil.com/forum/3549/
Fixed-point multiplication (C166 A*B/B)的更多相关文章
- ADC In An FPGA
http://davidkessner.wordpress.com/2011/05/01/adc-in-an-fpga/ Geek Alert! What follows is very techn ...
- c166 -div
unsigned short a=10; unsigned short b; unsigned short c;unsigned long d; b = (unsigned short)(d/2400 ...
- Position属性四个值:static、fixed、relative、absolute的区别和用法
1.static(静态定位):默认值.没有定位,元素出现在正常的文档流中(如果设置 top, bottom, left, right, z-index这些属性就不起做作了). 2.relative(相 ...
- fixed数据类型
在处理图形运算,特别是3D图形生成运算时,往往要定义一个Fixed数据类型,我称它为定点数,定点数其时就是一个整形数据类型,他的作用就是把所有数 进行转换,从而得到相应类型的整型表达,然后使用定点数进 ...
- CSS:position:fixed使用(转)
position属性规定元素的定位类型,即建立元素布局所用的定位机制.任何元素都可以定位,不过绝对定位或固定定位元素会生成一个块级框,而不论该元素本身是什么类型.相对定位元素会相对于它在正常流中的默认 ...
- setprecision **fixed
#include <iostream> #include <iomanip> using namespace std; int main( void ) { const dou ...
- Position属性四个值:static、fixed、absolute和relative的区别和用法
Position属性四个值:static.fixed.absolute和relative的区别和用法 在用CSS+DIV进行布局的时候,一直对position的四个属性值relative,absolu ...
- iframe中positioin:fixed失效问题
页面中嵌套的iframe 内的 position:fixed元素定位失效fixed正常页面 此时position:fixed是根据浏览器窗口定位的,下拉一直位于左上角:以iframe形式嵌入后 此时p ...
- setprecision、fixed、showpoint的用法总结
首先要加头文件:iomanip 一:setprecision 作用:控制输出流显示浮点数的数字个数,setprecision(n)就是输出的n个数,会有四舍五入. 比如:double s=20.784 ...
随机推荐
- php优秀框架codeigniter学习系列——constants.php
该文件位于application/config/constants.php.
- 并发的HTTP请求,apache是如何响应的,以及如何调用php文件的
作者:酒窝链接:https://www.zhihu.com/question/23786410/answer/153455460来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明 ...
- [Jedis] ERR wrong number of arguments for 'mget'
看别人写的代码是件比较痛苦的事情,更加痛苦的是别人的代码出错还要负责调试好. 关于如何迅速定位问题和调试代码,我的一点感受是:逐行认真查看错误信息,在这些信息中找自己熟悉的内容(包括文件名.方法名等) ...
- Microsoft Project 常用快捷键
任务升级 : ALT + SHIFT + 向左键 任务降级: ALT + SHIFT + 向右键 滚动到表头(第一个任务):Ctrl + HOME 滚动到表尾(最后一个任务):Ctrl + E ...
- 栈溢出原理与 shellcode 开发
ESP:该指针永远指向系统栈最上面一个栈帧的栈顶 EBP:该指针永远指向系统栈最上面一个栈帧的底部 01 修改函数返回地址 #include<stdio.h> #include< ...
- FZU 2273 Triangles 第八届福建省赛 (三角形面积交 有重边算相交)
Problem Description This is a simple problem. Given two triangles A and B, you should determine they ...
- 记第十四届省赛参赛体会&第十三届
emmm....时间还是很久远了 还是流水账 这次比赛我还是挺开心的 因为感觉我们余神就是一把宝剑,然后我是她的Buff 前面四道题就挺顺利都1A过了,十年余神就是强无敌呀 最后两分钟过了第五题,银牌 ...
- gcc/g++ 使用 tricks
0. 优化级别 -O0,不进行优化的编译后的文件大小反而更小,小于 -O2 的: 1. -std 指定 C 语言标准 -ansi -ansi == -std=c90 -std=c99:(std:sta ...
- win7英文版
下载个系统,不是一堆木马,就是一堆病毒:相对来说,我还是倾向于相信国外的镜像. https://pcriver.com/operating-systems/windows-7-ultimate-iso ...
- Buildroot Savedefconfig
/********************************************************************************* * Buildroot Saved ...