[comp.lang.asm370] Doubleword arithmetic

seb1525@support2.draper.COM (Steve Bacher) (09/26/90)

>From: Bahri Bora BALI AG <OPRJ36%TREARN.BITNET@cunyvm.cuny.edu>
>Subject: DoubleWord Number to be in a calculation and displayed

>Hello Steve. I got your sample from Asm list. I've been wondering how
>would I make some calculation with large numbers and display them by
>Assembler. I tried your sample code but I didn't succeed to get the
>result that I've been expecting. For example, I want to multiply
>'1234567890' (doubleword) number by '123456'. By your method in your
>sample, how could I do this ? Could you show me any way to do this?
>I am sending my sample (your modified code, by me) to you. Thank you
>very very much for your helps. Happy days.

You're talking about large-precision integer arithmetic now, and this gets
into some tricky areas.  Since a doubleword integer, when multiplied by
another integer, can easily result in a value larger than 64 bits, this is
not a trivial task,

Even if you use a straightforward grammar-school-arithmetic approach, there
are a number of special cases wrt signs and overflow that need to be kept
in mind.  You should be sure to exercise your code with a lot of well-
thought-out test cases.  Otherwise bugs will pop up and bite you when
you least expect them.  (Take it from any number of Lisp implementations.)

If you limit yourself to non-negative fullword*fullword=doubleword
calculations, you should be able to use the straight fullword multiply
instructions.

Hope this helps (and doesn't discourage you too much),

						- SEB