我在程序集中使用了堆棧,但我沒有關於推ebp和pop ebp的想法。有關在程序集中推ebp和pop ebp指令的說明
.intel_syntax noprefix
.include "console.i"
.text
askl: .asciz "Enter length: "
askb: .asciz "Enter breadth: "
ans: .asciz "Perimeter = "
_entry:
push ebp # establishing stack-frame
mov ebp, esp
sub esp, 12
Prompt askl
GetInt [ebp-4] # length
Prompt askb
GetInt [ebp-8] # breadth
mov eax, [ebp-4] # eax = l
add eax, [ebp-8] # eax = l + b
add eax, eax # eax = 2 * (l + b)
mov [ebp-12], eax
Prompt ans
PutInt [ebp-12]
PutEoL
mov esp, ebp
pop ebp # unwinding stack-frame
ret
.global _entry
.end
爲什麼你發佈整個代碼時,只有6條線懷疑? – Searock 2010-09-04 04:56:40
給予更多的上下文總是最好的。這就是說,真正的問題是非常模糊的,並會使用更多的解釋。 – 2010-09-06 13:39:11