Why did I still get the error "Divide overflow"

Reply

Join Date: Feb 2009
Posts: 1
Reputation: userqt is an unknown quantity at this point 
Solved Threads: 0
userqt userqt is offline Offline
Newbie Poster

Why did I still get the error "Divide overflow"

 
0
  #1
Feb 7th, 2009
That's the program I'm trying to wrote:
  1. .model small
  2. .stack 100h
  3. .data
  4. x dw 2
  5. array db 100 dup(?)
  6. even db 0
  7. unread db 0
  8. len=($-array)
  9. .code
  10. mov ax,@data
  11. mov ds,ax
  12. mov CX,len
  13. mov SI,0
  14. m1:
  15. mov ah,08h ;inputs a digit into al
  16. int 21h
  17. cmp al,27 ;is it esc?
  18. je m7 ;go to m7!
  19. cmp al,13 ;is it enter?
  20. je m7
  21. cmp al,'0' ;is it 0? if so, go to m2
  22. je m2
  23. cmp al,'1' ;s it 1? if so, go to m2
  24. je m2
  25. cmp al,'2' ;etc...
  26. je m2
  27. cmp al,'3'
  28. je m2
  29. cmp al,'4'
  30. je m2
  31. cmp al,'5'
  32. je m2
  33. cmp al,'6'
  34. je m2
  35. cmp al,'7'
  36. je m2
  37. cmp al,'8'
  38. je m2
  39. cmp al,'9'
  40. je m2
  41. jmp m1 ;if it's not esc, enter or digit then it's gotta be letter or contor symbol
  42.  
  43.  
  44. m2: ;this print inputed digit
  45. mov dl,al
  46. mov ah,02h
  47. int 21h
  48. mov [SI+array],dl ;write's the digit from dl into the array
  49. add SI,2 ;go to the array's next element
  50. jmp m1 ;get's back to input another digit
  51.  
  52. m7:
  53. mov si,0
  54. m8:
  55. mov dl,[SI+array] ;read's a element from the array
  56. mov ax,x ;make's ax 2
  57. div dl ;divide's the element to 2 <span class="ad_notxt"><code class="inlinecode">The problem is around here somwehre here!</code></span> cmp ah,0 ;if the remainder is zero, then the digit is even
  58. inc even ;incerase even (stores the number of even digits)
  59. inc unread ;else incerase unread (i'm not sure about this but I can fix it later, this is not what's causе the problem)
  60. inc si ;incerase source index
  61. loop m8 ;loop 'till reach the end of the array - len
  62. jmp the_end
  63.  
  64. the_end:
  65. mov dl,even ;trying to print the number of the even digits (not sure it will work)
  66. mov ah,02h
  67. int 21h
  68. mov ah,4ch ;return to operating system
  69. int 21h
  70. end

The point is to enter only digits and then to write them down to an array. Then I have to print the number of even and unread digits.
But I don't want help on this.

I just want to know why give's me the error "Divide overflow".
I start the program, write some digits and when I hit "enter" or "Esc" I get "Divide overflow".

The problem is somewere here
mov ax,x
div dl
I knew it!

Any help? Thanks!

(btw sorry for my crappy english, I'm from mars
Last edited by userqt; Feb 7th, 2009 at 6:28 pm.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Assembly Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC