Announcement

Collapse
No announcement yet.

Assembly.... masm... divide overflow.... HELP!!!!!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Assembly.... masm... divide overflow.... HELP!!!!!

    I don't know what causes this... I can not imagine. I get divide by 0 errors all the damn time, I can not for the life of me figure out why. I almost never use the division instruction(which is problematic as you might imagine!) because every time I do I get a divide by zero error.....

    Now I don't get it ALL the time. For example if the first instruction in my program is:

    mov ax, 1439
    mov bx, 16
    div bx

    it will work

    SOMETIMES I can even do:

    mov ax, 1439
    mov bx, 16
    div bx
    div bx
    dix bx


    and the error won't come till the third div bx. If I put this code in a procedure far down in my program, a divide by zero error is often caused by the first division.... for the love of all that is good and holy I can NOT figure this out, any ideas? Is this my computer not having enough memory? That makes no sense... WHAT THE HELL IS CAUSING THIS?

  • #2
    Divide underflow?

    Comment


    • #3
      Divide OVERFLOW.

      For the life of me I can not figure this out.

      Comment


      • #4
        I thought you got underflow errors when you divided by a really small number...

        Comment


        • #5
          I am getting a divide overflow error, trying to divide 1439 by 16, repetadly.

          When I do that I get AX to be 59h and when I try to divide 59h by 16, I get a divide overflow... this makes no sense.
          Last edited by Vesayen; March 27, 2005, 15:47.

          Comment


          • #6
            Try just dividing 59h by 16.

            Comment


            • #7
              Works fine.

              Comment


              • #8
                Any ideas why succesive divisions will not work? My laptop I am running this on is not great but pretty good,, it runs never winter nights....

                Comment


                • #9
                  what registers does div modify?

                  Comment


                  • #10
                    "div bx" takes the unsigned int in the register pair dx:ax, divides it by the unsigned int in bx, puts the quotient in ax, and puts the remainder in dx. It raises #de in case the divisor is 0 or the quotient is too big to fit in the target register.

                    That's the way I understood it, anyway. I've never actually written asm in my life...
                    This is Shireroth, and Giant Squid will brutally murder me if I ever remove this link from my signature | In the end it won't be love that saves us, it will be mathematics | So many people have this concept of God the Avenger. I see God as the ultimate sense of humor -- SlowwHand

                    Comment


                    • #11
                      so whats in dx during all this?

                      Comment


                      • #12
                        Whoha raises the question!

                        Comment


                        • #13
                          if dx starts at zero the first 3 divisions should "work" but thats probably not the case. a high enough dx should put greater then 65535 in ax and thats like your problem. any dx greater then 16 will generate this.

                          Comment


                          • #14
                            I can't see a way dx should become greater than div's source operand, though. If something else uses dx, sure, but as far as I know, the remainder should always be smaller than the divisor in a division
                            This is Shireroth, and Giant Squid will brutally murder me if I ever remove this link from my signature | In the end it won't be love that saves us, it will be mathematics | So many people have this concept of God the Avenger. I see God as the ultimate sense of humor -- SlowwHand

                            Comment


                            • #15
                              Run the program through a debugger. Put a breakpoint before the third DIV, and check the various register values.
                              (\__/) 07/07/1937 - Never forget
                              (='.'=) "Claims demand evidence; extraordinary claims demand extraordinary evidence." -- Carl Sagan
                              (")_(") "Starting the fire from within."

                              Comment

                              Working...
                              X