C的calling convention:
假設在main()裡面有下面這一行C程式碼
string_copy(s, d, len);
這行C程式碼對應到的組合語言為:
push len
push d
push s (反向push)
call string_copy
pop (caller要負責clean up the stack,換句話說,asm裡面並不需要將參數pop出堆疊)
pop
pop
此外,回傳值會被存在eax暫存器
結論:
(1) 參數會以由右到左的順序push進堆疊
(2) 回傳值會被存在eax暫存器
(3) caller要負責clean up the stack