1.åºå寻åååå寻åçåºå«
åºå寻åååå寻åçåºå«
SPæ¯å æ æéå¯åå¨ï¼ä¸é¨ç¨æ¥ç»´æ¤å æ çï¼è¯¸å¦POPï¼PUSHï¼CALLçæ令é½æ¯è·SPç¸å ³çï¼æ以SP对äºç¨åºæ¥è¯´æ¯åºè¯¥æ¯åªè¯»çï¼èå®é ä¸ä½ å¯ä»¥æå¨è®¾ç½®SPçå¼ãå¦æç¨SPä½ä¸ºåºå°åçè¯ï¼ä¼åºéçãèBPæ¯å æ çåºåæéï¼å¦æä¸ä½¿ç¨æ®µè¶ è¶æ å¿çè¯ï¼BPå®é ä¸æ¯SSï¼BPï¼å°±åSIé»è®¤æ¯DSï¼SI
ï¼DIé»è®¤æ¯ESï¼DIï¼è¿æ¯ä¸æ ·çéçã
BPå¨Cè¯è¨ç¨åºä¸ä½¿ç¨å¹¿æ³ï¼ä¾å¦ä¸é¢çCç¨åºç¼è¯ä¸ºæ±ç¼åºè¯¥æ¯è¿æ ·
//C:
int
sum(int
a,语言自unity坦克大战 源码int
b
)
{
DoSometing();
return
a+b;
}
...//å¨å ¶ä»çå½æ°ä¸
c=sum(1,2);
...
;ASM:
sum
proc
push
bp
mov
bp,sp
;å°spçå¼éå°bpï¼è®©bpæåæ 顶
call
DoSomething
mov
ax,[bp+4]
;[bp+4]
=
a
add
ax,[bp+6]
;[bp+6]
=
b
pop
bp
ret
4
sum
endp
...
;å¨å ¶ä»çå½æ°ä¸
mov
ax,2
;第äºä¸ªåæ°
push
ax
mov
ax,1
;第ä¸ä¸ªåæ°
push
ax
call
sum
mov
addr_c,ax
;addr_cæ¯æåå®çcåéçå°å.
...
ä»ä»¥ä¸çä¾åçæ¥ï¼ä½¿ç¨BPæ¯æ£ç¡®çï¼èä¸åºè¯¥æ¯SPï¼SPæ¯ä¸ç¨å¯åå¨ï¼ä¸è¦å¨å®ä¸ºå¥½ãå°å®çå¼éç»BPå°±è¡äºï¼ä¸ç®¡ä½ ä¹åæ§è¡äºinc
bp
è¿æ¯
add
bp,2ï¼é½ä¸ä¼å½±åå æ çå·¥ä½ã