Im doing the tutorial on rich edits from iczelions site. Heres the code i have... ;========================================================================================================= StreamInProc proc hFile:DWORD, pBuffer:DWORD, NumBytes:DWORD, pBytesRead:DWORD mov eax, 100 div NumBytes mul pBytesRead invoke wsprintf, addr Buffer, addr FormatString5, eax invoke SetWindowText, hMainStatus, addr Buffer invoke ReadFile, hFile, pBuffer, NumBytes, pBytesRead, 0 xor eax, 1 ret StreamInProc endp ;========================================================================================================= What im trying to do is get the percent read and then diplay it in a status bar. But i get an overflow error. The error is at the line div NumBytes When i leave that line out, i dont get an error. If anyone has any idea why it does that, please tell me!
Posted on 2001-02-21 12:28:00 by HeroInc
The div opcode divides edx:eax (a 64 bit number) by a 32-bit operand (in your case). But you have only set eax before the div instruction, not edx, so edx can be anything causing an overflow in the division (the result does not fit in eax). You'll have to clear edx before your division, either by
mov eax, 100
xor edx, edx
div NumBytes
or
mov eax, 100
cdq
div NumBytes
(cdq extends a dword in eax to a quadword in edx:eax) Thomas This message was edited by Thomas, on 2/21/2001 3:03:34 PM
Posted on 2001-02-21 15:02:00 by Thomas