• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
  • slider image 488
  • slider image 491
:::


Browsing this Thread:   1 Anonymous Users






Re: 請教一個32bit的數,如何快速取它的高16bit?
#7
資深會員
資深會員


查看用戶資訊
又不是 浮點數 直接抓不行嘛 ?????????????


8組一派

發表於: 2009/3/11 15:23
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請教一個32bit的數,如何快速取它的高16bit?
#6
資深會員
資深會員


查看用戶資訊
您試試:
test2 = ( (long) test1 )>>16;
雖然看起來跟"test2 = test1>>16;"一樣, 但是有些組譯器會知道不需要使用位移方式, 效果跟union一樣. 你可以試試!!
它牌dsp組譯器也是如此.

發表於: 2009/3/11 11:24
Thanks,
Edward Lee
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請教一個32bit的數,如何快速取它的高16bit?
#5
高級會員
高級會員


查看用戶資訊
直接用指针也可以的吧.

test2 = *(&test1) ;
test2 = *(&test1+1) ;
test2 = *(&test1-1) ;

测试测试,看哪个是对的,嘿嘿.

發表於: 2009/3/9 11:57
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請教一個32bit的數,如何快速取它的高16bit?
#4
新會員
新會員


查看用戶資訊
參照:

jackyli37 寫道:
參照:

nicecookie 寫道:
改用union 的話會快點嗎?



請問才用union的方式共用ram的位址,怎麼知道取的是高16位的data呢?
能不能麻煩指導一下or給個例子,謝~


Dear All:
我 try 出來了,分享一下:

union{
int a[2];
long b;
}test;

test.b = 0x12345678;

那麼 test.a[0] = 0x5678
test.a[1] = 0x1234

run了一下,只需2個cycle,謝謝幫忙~

發表於: 2009/3/8 15:38
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請教一個32bit的數,如何快速取它的高16bit?
#3
新會員
新會員


查看用戶資訊
參照:

nicecookie 寫道:
改用union 的話會快點嗎?



請問才用union的方式共用ram的位址,怎麼知道取的是高16位的data呢?
能不能麻煩指導一下or給個例子,謝~

發表於: 2009/3/8 14:59
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請教一個32bit的數,如何快速取它的高16bit?
#2
資深會員
資深會員


查看用戶資訊
改用union 的話會快點嗎?

發表於: 2009/3/7 15:52
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


請教一個32bit的數,如何快速取它的高16bit?
#1
新會員
新會員


查看用戶資訊
Dear All:

程式如下:

int test1 __attribute__((address(0x1000)))
int test2 ;

test1 = 0x12345678 ;
test2 = test1>>16;

請教各位先進,我run了一下上面右移的方式,也要10個cycle。

如果用下面指令,抓到的卻是0x1008位址的ram。
test2 = *(&test1+2) ;


請問除了右移外,有沒有更快的方式,可以取test1的高位0x1234嗎?

因為小弟在run一個Algorithm,一個loop只有100uS, 裡面就要用到上述取100個ram的高位,也就是要1000個cycle,25uS(40MIPS來算的話),很浪費時間,不知道各位有沒有什麼好方法?

發表於: 2009/3/7 14:03
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------