请教P71页的小程序
《软件调试》答疑
请教P71页的小程序
Landy
2010-03-08, 21:32 下午
P71页清单3-1 演示错误类异常的Fault小程序
在我的Visual Studio 2008的环境里,运行这个程序,进入无限循环。输出结果是
Before div in __try block:nDividend=22, nDivisor=0, nResult=100
In __except block: nDividend=22, nDivisor=0, nResult=100
Divided by zero detected: nDividend=22, nDivisor=1, nResult=100
In __except block: nDividend=22, nDivisor=1, nResult=100
Divided by zero detected: nDividend=22, nDivisor=1, nResult=100
In __except block: nDividend=22, nDivisor=1, nResult=100
Divided by zero detected: nDividend=22, nDivisor=1, nResult=100
In __except block: nDividend=22, nDivisor=1, nResult=100
Divided by zero detected: nDividend=22, nDivisor=1, nResult=100
In __except block: nDividend=22, nDivisor=1, nResult=100
Divided by zero detected: nDividend=22, nDivisor=1, nResult=100
In __except block: nDividend=22, nDivisor=1, nResult=100
//Ctrl+C..
从输出看,nDivisor已经是1了,为什么还在不断触发DIVIDE_BY_ZERO异常?
谢谢!
Re: 请教P71页的小程序
格蠹老雷
2010-03-09, 12:44 下午
因为VS2K8产生的除法指令是用寄存器做除数,请参考下面这个帖子来解决这个问题:
http://advdbg.com/forums/1292/ShowPost.aspx
Re: 请教P71页的小程序
Landy
2010-03-09, 21:31 下午
谢谢张老师!