raymond,你好
我按照第三章的fault.cpp书上的代码,在vc2005里面调试,发现执行到__except块后,程序一直不退出,不断打印:
Before div in __try block:nDiviedend=22, nDivisor=0, nResult=100. In __except block:nDiviedend=22, nDivisor=0, nResult=100. Divide Zero exception detected:nDiviedend=22, nDivisor=1, nResult=100. In __except block:nDiviedend=22, nDivisor=1, nResult=100. Divide Zero exception detected:nDiviedend=22, nDivisor=1, nResult=100. In __except block:nDiviedend=22, nDivisor=1, nResult=100. Divide Zero exception detected:nDiviedend=22, nDivisor=1, nResult=100. In __except block:nDiviedend=22, nDivisor=1, nResult=100. Divide Zero exception detected:nDiviedend=22, nDivisor=1, nResult=100. In __except block:nDiviedend=22, nDivisor=1, nResult=100. Divide Zero exception detected:nDiviedend=22, nDivisor=1, nResult=100. ……
后来在下载了书上配套的源码,发现和书上不同的是已经把 nResult=nDividend / nDivisor; 这一句改成了汇编:
// nResult=nDividend / nDivisor; __asm{ mov eax, nDividend cdq idiv nDivisor mov nResult, eax };
参照配套的源码修改后,vc2005里面程序执行的流程也正常了。 请问这可能是什么原因?
|