Re: DIV overflow
- From: "Wolfgang Kern" <nowhere@xxxxxxxx>
- Date: Sat, 31 Mar 2007 18:22:12 +0200
Hello Brian,
What are good solutions to preventing DIV overflow?
Best solution would be to avoid DIV at all,
but unfortunately not always very practical.
An easy way is to always have dx just a sign extension of ax,
so for your example better use 32-bit DIV.
MOVZX ebx, word divisor ;if you want a 16-bit divisor
MOV eax, dword dividend
CDQ ;edx=Sign eax 0 or -1 (becomes 0 yet)
DIV ebx ;cannot overflow then
Better replace CDQ with XOR edx,edx for UNsigned DIV.
__
wolfgang
:) we always post it twice ?
.
- Follow-Ups:
- Re: DIV overflow
- From: Brian
- Re: DIV overflow
- References:
- DIV overflow
- From: Brian
- Re: DIV overflow
- From: Wolfgang Kern
- DIV overflow
- Prev by Date: Re: ascii to tword - help
- Next by Date: Re: ascii to tword - help
- Previous by thread: Re: DIV overflow
- Next by thread: Re: DIV overflow
- Index(es):
Relevant Pages
|
|