CnPack Forum


 
Subject: 《Basm初学者入门》中的一个错误
stalker
新警察
Rank: 1



UID 41586
Digest Posts 0
Credits 4
Posts 1
点点分 4
Reading Access 10
Registered 2009-1-5
Status Offline
Post at 2009-1-5 18:56  Profile | Blog | P.M. 
《Basm初学者入门》中的一个错误

该错误位于12页
如下:

QUOTE:

Then there are only three lines of asm back to explain.
这三行返回代码需要解释一下:
{
pop ecx
pop ecx
pop ebp
}
end;
These are removing the stack frame, by restoring the values of esp and ebp back
to the values they had when the function was entered. This code is much more
intuitive and does the same thing
add esp, 4
pop ebp
it is also more effective and I do not know why the compiler is incrementing the
stack pointer in this cumbersome way. Remember that ecx can be used for free and
assigning values to it is just like pouring them into a waste bucket.
它们弹出堆栈,恢复进入函数时保存的 esp、ebp 的值。更形象的表示如下
add esp, 4
pop ebp
这也是更有效率的。我不知道为什么编译器用那样麻烦的方法增加堆栈指针。
记得 ecx 可以被自由使用和复制,pop ecx 看起来像把数据放到了垃圾桶。

很明显
pop ecx
pop ecx
pop ebp
应该等同于
add esp,8
pop ebp
才对
Top
skyjacker
版主
Rank: 7Rank: 7Rank: 7
茶农


UID 2239
Digest Posts 9
Credits 617
Posts 269
点点分 617
Reading Access 100
Registered 2006-6-8
Status Offline
Post at 2009-1-10 19:53  Profile | Blog | P.M.  | QQ
对,应该+8




一壶清茶煮青春.
Top
 




All times are GMT++8, the time now is 2024-11-22 10:01

    本论坛支付平台由支付宝提供
携手打造安全诚信的交易社区 Powered by Discuz! 5.0.0  © 2001-2006 Comsenz Inc.
Processed in 0.008238 second(s), 9 queries , Gzip enabled

Clear Cookies - Contact Us - CnPack Website - Archiver - WAP