Re: Assemblers are for hiding your work , not for faster code .



On 11 Jan 2007 07:58:11 -0800, "Didi" <dp@xxxxxxxxxxx> wrote:

Hi John,

... which was both bad and customer-visible.

I also have found out that this combination won't go from itself
in instrumentation making, eventually we have to act on it :-).

I tested it in PowerBasic (using 64-bit integer variables) and it does
seem to work. 4 lines of real code, not bad.

I am not quite sure what your assembler does, but the second "divu"
line seems suspicious to me (looks like you just overwrite the
remainder
from the first div and divide d1 instead).

I'm concatenating the 32-bit remainder (actually, 0..9) above the
32-bit low input. DIVU.Q divides 64/32, with a 32-bit quotient and a
32-bit remainder. Which makes it...



Given a 64-bit thing as H:L halves, each 32 bits,

Divide 0:H by 10 ; quotient is MS output, leaving remainder R

Concatenate R:L, divide by 10, and result is low output


I later realized that this is exactly (well, almost) the long-division
procedure we learned in 4th grade. The manual, decimal procedure is..

1. divide some arbitrary number of numerator digits by the
denominator, whatever you can handle, and post the quotient digits.

2. drop down the remainder, and drop one or more numerator digits to
the right of that,

3. Goto 1


I'm just doing it in fixed 32-bit chunks. Now, finally after all these
years, I sort of understand long division.

John




.



Relevant Pages

  • Re: 64 by 32 bit division
    ... quotient and the remainder, and is it signed or an unsigned division? ... And when you divide ... use of the fact that the lower / higher word is zero. ...
    (comp.lang.forth)
  • Re: Fast Binary to BCD method on ARM9 with huge numbers?
    ... >> largest power of ten you can comfortably divide by. ... quotient. ... As to the remainder, the above does not generate it, and you have to ... multiplications and some simple logic. ...
    (comp.arch.embedded)
  • Re: Ali Muses on a Party Piece
    ... making a 6 digit number" ... "Now divide the quotient by 11, and add the remainder to the previous ... "Now divide the quotient by 7, and add the remainder to the sum of the ...
    (uk.people.silversurfers)
  • Re: break a 10 digit number up into five sets of two digits
    ... with pure math not using a programing lang.? ... find the quotient q1 and remainder r1 ... and remainder when you divide q1 by 100: ...
    (sci.math)
  • Re: If you were inventing CoBOL...
    ... ANSI X3.23-1968 is also regularly referred to as "First Standard COBOL". ... COBOL rules before 1968 were pretty much a gentlemen's agreement, ... I often want just the remainder, ... For example: divide 7 into ...
    (comp.lang.cobol)