精華區beta CSSE 關於我們 聯絡資訊
請問一下calling convention, caller save register及callee save register,與下面這些敘述有什麼關聯嗎? pascal convention 規定:三數傳遞次序由左而右,stack frame 的清理由被呼叫端( callee)負責。 c convention 規定:三數傳遞次序由右而左,stack frame 的清理由呼叫端(caller) 負責。 由於 pascal convention 規定 stack frame 的清理由被呼叫端(callee)負責,因此如 對同一函式呼叫一千次,其 stack frame cleanup routine只需一份(位於 callee 內, 由編譯器加入)。 由於 c convention 規定 stack frame 的清理由呼叫端(caller)負責,因此對同一個 函式呼叫一千次,其 stack frame cleanup routine需 1000 份(位於呼叫點,由編譯器 加入)。 因此,採用 pascal calling convention,對於降低程式碼大小(並因而增加執行速度) ,在某些情況下很有幫助。這是為什麼早期 Windows 系統內部幾乎完全採用 pascal calling convention 的原因。 但是 pascall convention 不支援「個數不定之引數」。例如 printf()的引數個數不一 定,那就一定得使用 c calling convention。 還有下面這句,我也不太懂它的意思.. If a procedure is called n times, then the portion of the calling sequence in the various callers is generated n times. However, the portion of the callee is shared by calls, so it is generated just once. Hence, it is desirable to put as much of the calling sequence into the callee as possible. 最後請問calling convention與call by value, call by reference, call by name.. 又有什麼關聯呢? 請問小弟我是不是什麼核心觀念沒弄清楚,所以才會產生前述的混淆.. 請板上前輩指點一下..謝謝.. -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.119.201.20