943,899 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Unsolved
  • Views: 1365
  • Assembly RSS
Jan 4th, 2009
0

divide overflow issue

Expand Post »
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:
assembly Syntax (Toggle Plain Text)
  1. prt_sig:
  2. mov al,[bx+si]
  3. mov ah,0
  4. ;the maximum digit in a number is 3
  5. push cx
  6. mov cx,3
  7. pr:
  8. xor dx,dx
  9. push bx
  10. mov bx,10
  11. div bx
  12. add dl,30h
  13. pop bx
  14. push dx
  15. xor ah,ah
  16. dec cx
  17. cmp cx,0
  18. jne pr
  19. mov cx,3
  20. prin:
  21. pop dx
  22. mov ah,02h
  23. int 21h
  24. loop prin

tnx
Last edited by Ancient Dragon; Jan 4th, 2009 at 6:12 pm. Reason: add code tags
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
loudstil is offline Offline
5 posts
since Mar 2008
Jan 5th, 2009
0

Re: divide overflow issue

Click to Expand / Collapse  Quote originally posted by loudstil ...
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.
Reputation Points: 99
Solved Threads: 5
Junior Poster
Evenbit is offline Offline
140 posts
since Mar 2005
Jan 5th, 2009
0

Re: divide overflow issue

Click to Expand / Collapse  Quote originally posted by Evenbit ...
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.....
Reputation Points: 10
Solved Threads: 0
Newbie Poster
loudstil is offline Offline
5 posts
since Mar 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Assembly Forum Timeline: Converting a string of numbers to an integer
Next Thread in Assembly Forum Timeline: Assembly Symbols with the code?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC