Odd Calling Convention

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Odd Calling Convention

ソリューションへジャンプ
757件の閲覧回数
jimfell
Contributor III

I working with an existing code base, and I came across this function that is called durning normal program execution to modify the Interrupt Priority Level (IPL) bits of the Status Register (SR):

 

 

__declspec (register_abi) asm unsigned int asm_set_ipl(unsigned int mask)

 

I'm unfamiliar with this.  What is this convention suppose to be doing?  (Yes, all the code in this function is assembly.)  As nearly as I can tell, this is just stating that this is an assembly function.  Is that all this convention is doing?  I am using CodeWarrior 10.  Thanks.

 

 

ラベル(1)
0 件の賞賛
返信
1 解決策
623件の閲覧回数
BlackNight
NXP Employee
NXP Employee

Yes, I have seen that in several places used. It is not CodeWarrior specific. I think 'ipl' stands for 'Interrupt Priority Level': using that (assembly) function you pass the new interrupt mask and on return you get the previously set interrupt level back. So you could use it like

oldLevel = asm_set_ipl(MASK_ALL_INTERRPTS); /* disable interrupts */

critical section here;

(void) asm_set_ipl(oldLevel); /* restore previous interrupt level */

If the question is about what the __declspec(register) is about: this tells the compiler to use 'register' calling convention (instead of passing the parameters on the stack).

Hope this helps,

Erich

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
624件の閲覧回数
BlackNight
NXP Employee
NXP Employee

Yes, I have seen that in several places used. It is not CodeWarrior specific. I think 'ipl' stands for 'Interrupt Priority Level': using that (assembly) function you pass the new interrupt mask and on return you get the previously set interrupt level back. So you could use it like

oldLevel = asm_set_ipl(MASK_ALL_INTERRPTS); /* disable interrupts */

critical section here;

(void) asm_set_ipl(oldLevel); /* restore previous interrupt level */

If the question is about what the __declspec(register) is about: this tells the compiler to use 'register' calling convention (instead of passing the parameters on the stack).

Hope this helps,

Erich

0 件の賞賛
返信
623件の閲覧回数
jimfell
Contributor III

Thanks!

0 件の賞賛
返信