Re: 請教一個32bit的數,如何快速取它的高16bit?
|
||||
---|---|---|---|---|
資深會員
|
又不是 浮點數 直接抓不行嘛 ?????????????
8組一派
發表於: 2009/3/11 15:23
|
|||
|
Re: 請教一個32bit的數,如何快速取它的高16bit?
|
||||
---|---|---|---|---|
資深會員
|
您試試:
test2 = ( (long) test1 )>>16; 雖然看起來跟"test2 = test1>>16;"一樣, 但是有些組譯器會知道不需要使用位移方式, 效果跟union一樣. 你可以試試!! 它牌dsp組譯器也是如此.
發表於: 2009/3/11 11:24
|
|||
Thanks,
Edward Lee |
||||
|
Re: 請教一個32bit的數,如何快速取它的高16bit?
|
||||
---|---|---|---|---|
高級會員
|
直接用指针也可以的吧.
test2 = *(&test1) ; test2 = *(&test1+1) ; test2 = *(&test1-1) ; 测试测试,看哪个是对的,嘿嘿.
發表於: 2009/3/9 11:57
|
|||
|
Re: 請教一個32bit的數,如何快速取它的高16bit?
|
||||
---|---|---|---|---|
新會員
|
參照:
請問才用union的方式共用ram的位址,怎麼知道取的是高16位的data呢? 能不能麻煩指導一下or給個例子,謝~
發表於: 2009/3/8 14:59
|
|||
|
Re: 請教一個32bit的數,如何快速取它的高16bit?
|
||||
---|---|---|---|---|
資深會員
|
改用union 的話會快點嗎?
發表於: 2009/3/7 15:52
|
|||
|
請教一個32bit的數,如何快速取它的高16bit?
|
||||
---|---|---|---|---|
新會員
|
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
|
|||
|