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

Recommended Answers

All 2 Replies

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.

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.....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.