0

Hi to all,
I wrote a code, and it gives me divide overflow, but the issue here is that when I run the program trough the debugger it works fine, but when I run the program in the dos mode it gives me Divide overflow error. here the code:

prt_sig:
				mov		al,[bx+si]
				mov		ah,0
				;the maximum digit in a number is 3
				push	cx
				mov		cx,3
				pr:
					xor		dx,dx
					push	bx
					mov		bx,10
					div		bx
					add		dl,30h
					pop		bx	
					push	dx
					xor		ah,ah
					dec		cx
					cmp		cx,0
					jne		pr
					mov		cx,3
				prin:
					pop		dx
					mov		ah,02h
					int		21h
					loop	prin

tnx

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by loudstil
0

Hi to all,
I wrote a code, and it gives me divide overflow, but the issue here is that when I run the program trough the debugger it works fine, but when I run the program in the dos mode it gives me Divide overflow error. here the code:

tnx

Insert a CWD instruction right before the DIV instruction. This will sign-extend AX into the DX:AX pair needed for the ('dword' divided by 'word') division.

Nathan.

0

Insert a CWD instruction right before the DIV instruction. This will sign-extend AX into the DX:AX pair needed for the ('dword' divided by 'word') division.

Nathan.

Thanks for the fast replay

I tried to put cwd before the DIV instruction, but it still gives me DIVIDE OVERFLOW.....

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.