Re: How multiply two __int64 ...

Discussion in 'C Programming' started by jacob navia, Nov 1, 2010.

  1. jacob navia

    jacob navia Guest

    Le 31/10/10 10:34, Kappa a écrit :
    > Hi,
    >
    > I was wondering if someone has already written a routine to multiply two
    > __int64 for obtain a __int128.
    >
    > Can someone help me ?
    >
    > Thanks very much.
    >
    > K.
    >
    >

    Yes, I have written one for my compiler system lcc-win.

    Now, you have two choices:

    (1) Stealing it.
    (2) Buying it.

    I will start with the more expensive option:

    (1) Stealing it.

    Write a small program like this using lcc-win:

    #include <int128.h>

    int main(void)
    {
    int128 a=12LL,b=10LL;
    int128 c=a*b;
    }

    Compile it with debug info and start the debugger. Put a breakpoint in
    the line with the multiplication. When the debugger stops there, open
    the disassembly window and press F8 (step in). You will eventually
    arrive at the multiplication procedure. List its assembly contents
    and you have a 64*64 multiplication routine.

    This is more expnsive of course because you will spend a lot of time
    doing this.

    Much cheaper is the second option:

    (2) Buy a paying version of lcc-win (www.q-software-solutions.de) and I
    will send you the source code in assembly. (32 bits).

    jacob
    jacob navia, Nov 1, 2010
    #1
    1. Advertising

  2. jacob navia

    BartC Guest

    "jacob navia" <> wrote in message
    news:iamm82$p7d$...
    > Le 31/10/10 10:34, Kappa a écrit :


    >> I was wondering if someone has already written a routine to multiply two
    >> __int64 for obtain a __int128.


    > Write a small program like this using lcc-win:
    >
    > #include <int128.h>
    >
    > int main(void)
    > {
    > int128 a=12LL,b=10LL;
    > int128 c=a*b;
    > }
    >
    > Compile it with debug info and start the debugger. Put a breakpoint in the
    > line with the multiplication. When the debugger stops there, open the
    > disassembly window and press F8 (step in). You will eventually arrive at
    > the multiplication procedure. List its assembly contents
    > and you have a 64*64 multiplication routine.


    How do you get the 128*128-bit routine?

    --
    Bartc
    BartC, Nov 1, 2010
    #2
    1. Advertising

  3. jacob navia

    jacob navia Guest

    Le 01/11/10 16:41, BartC a écrit :
    > "jacob navia" <> wrote in message
    > news:iamm82$p7d$...
    >> Le 31/10/10 10:34, Kappa a écrit :

    >
    >>> I was wondering if someone has already written a routine to multiply two
    >>> __int64 for obtain a __int128.

    >
    >> Write a small program like this using lcc-win:
    >>
    >> #include <int128.h>
    >>
    >> int main(void)
    >> {
    >> int128 a=12LL,b=10LL;
    >> int128 c=a*b;
    >> }
    >>
    >> Compile it with debug info and start the debugger. Put a breakpoint in
    >> the line with the multiplication. When the debugger stops there, open
    >> the disassembly window and press F8 (step in). You will eventually
    >> arrive at the multiplication procedure. List its assembly contents
    >> and you have a 64*64 multiplication routine.

    >
    > How do you get the 128*128-bit routine?
    >


    Actually reading the code above, you are calling the 128 multiply since
    a and b are 128 bit ints,

    What a stupid!

    To get the 64*64-->128 you just have to do a normal 64 bit
    multiply since ALL 64*64 yield a 128 Bit result in the intel
    machines, stored in RAX:RDX

    Sorry.
    jacob navia, Nov 1, 2010
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jam
    Replies:
    3
    Views:
    2,774
    Martin Thompson
    Sep 15, 2004
  2. Replies:
    12
    Views:
    2,629
    Slartibartfast
    Sep 23, 2003
  3. Ben Bacarisse

    Re: How multiply two __int64 ...

    Ben Bacarisse, Oct 31, 2010, in forum: C Programming
    Replies:
    3
    Views:
    429
  4. BartC

    Re: How multiply two __int64 ...

    BartC, Nov 1, 2010, in forum: C Programming
    Replies:
    0
    Views:
    582
    BartC
    Nov 1, 2010
  5. Jon

    Re: How multiply two __int64 ...

    Jon, Nov 6, 2010, in forum: C Programming
    Replies:
    6
    Views:
    416
    David Thompson
    Nov 16, 2010
Loading...

Share This Page