dspic中的 frame pointer 是要做何用
|
||||
---|---|---|---|---|
初級會員
|
請問dspic中的 frame pointer 是要做何用?
要如何使用呢? 它和 lnk 及 ulnk 有關係?
發表於: 2004/9/4 9:59
|
|||
|
Re: dspic中的 frame pointer 是要做何用
|
||||
---|---|---|---|---|
新會員
|
frame pointer是用来为所调用的子程序的临时变量分配存储空间的。
LNK和ULNK是用来开始创建 STACK FRAME和结束STACK FRAME的,经常能用到的。
發表於: 2004/9/8 16:45
|
|||
|
Re: dspic中的 frame pointer 是要做何用
|
||||
---|---|---|---|---|
初級會員
|
不知能否舉個簡單例子,說明frame pointer的用法
謝謝!
發表於: 2004/9/9 10:24
|
|||
|
Re: dspic中的 frame pointer 是要做何用
|
||||
---|---|---|---|---|
版主
|
1. W14 can be used as a stack frame pointer (FP)
2. LNK #N ; Allocates (N-2)/2 words of local storage - W14 (prior stack FP) is stacked; W15 is incremented - W15 value saved in W14 (new FP, start of local storage) - W15 advanced by N/2 words (end of local storage + 1 word)(i.e. N must be an even number to keep stack word aligned) - [W14 + y] accesses local storage for function callwhere: 0 <= y <= N-2 - W14 with a -ve offset accesses parameters from calling routine 3. ULNK ; De-allocates temporary storage space - Restores W14 (start of local storage) to W15 - W15 decremented then stack popped into W14 (prior stack FP).
發表於: 2004/10/1 16:57
|
|||
|
Re: dspic中的 frame pointer 是要做何用
|
||||
---|---|---|---|---|
中級會員
|
那這個東西通常都是怎麼用的啊?這個臨時性的空間到底有什麼用途呢?是不是像是C語言函數中的『區域變數』啊?
發表於: 2004/11/30 14:29
|
|||
|
Re: dspic中的 frame pointer 是要做何用
|
||||
---|---|---|---|---|
版主
|
1、聽我同事做實驗後說,在C程式中,呼叫某一函數後,W14及W15都會被牽動到。
2、我想,還可以利用它,甚至在使用組合語言時,都可以做到自已呼叫自已,類似所謂「遞迴」的寫法;其中使用W14來指到每一層函數中的變數。
發表於: 2004/12/1 23:55
|
|||
|
Re: dspic中的 frame pointer 是要做何用
|
||||
---|---|---|---|---|
中級會員
|
我做實驗的結果是在C程式中呼叫某一函數後,翻成組合語言一看會自動LNK數個byte的大小,此大小剛好就是被呼叫函數中所有的區域變數(包含參數),但是除了遞迴之外是否還有其他的用途?或是就是為了C語言所做出來的功能呢?
發表於: 2004/12/2 14:49
|
|||
|