Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Re: Macro To Ge...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 7 of 18 Topic 9553 of 9831
Post > Topic >>

Re: Macro To Generate Inline Assembly

by Le Chaud Lapin <jaibuduvin@[EMAIL PROTECTED] > Apr 28, 2008 at 11:23 PM

On Apr 28, 9:34 pm, Mathias Gaunard <loufo...@[EMAIL PROTECTED]
> wrote:
> On 27 avr, 15:29, Le Chaud Lapin <jaibudu...@[EMAIL PROTECTED]
> wrote:
>
> > I tried:
>
> > #define MULTIPLY(A, B, lower_word, upper_word)\
> > {\
> >         _asm mov eax, A;\
> >         _asm mul B;\
> >         _asm mov upper_word, edx;\
> >         _asm mov lower_word, eax;\
>
> > }
>
> What's the point of using macros? Use functions

Functions would make things worse (slower). They would add prolog and
epilog code. At the very least, a CALL/RET pair would have to be
executed using straight C++ code.  Trickery to get rid of the prolog/
epilog code would not help, nor would making the function inline,
because the problem is the C++ code itself. The part that does the
mathematical operations is too slow, and it is logically impossible
for the programmer to do anything about it, in C++.

For example, in a Big Integer class, on say, a 32-bit machine, for
optimal speed, one would necessarily have to multiply two 32-bit
numbers, A * B to yield a 64-bit result. It is impossible to achieve
the efficiency of a hardware-based 32-bit * 32-bit multipication using
****table C++ code.

Big integers are used as the basis of the RSA and DSA ciphers, and
asymmetric crytopsystems in general, for example, and such asymmetric
ciphers are used for packet signing in communications.  Because
asymmetric crypto is often the bottleneck in secure communications,
their execution speed is paramount. It would be hard to ignore a 3x or
4x increase in speed by switching to assembly versus C++.

If the reasons for adding __asm to C++ were listed in order of
im****tance, I'd say speed up of critical operations would be in the
top 10. :)

-Le Chaud Lapin-


-- 
      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 18 Posts in Topic:
Macro To Generate Inline Assembly
Le Chaud Lapin <jaibud  2008-04-27 07:29:36 
Re: Macro To Generate Inline Assembly
=?ISO-8859-1?Q?Daniel_Kr=  2008-04-27 12:39:09 
Re: Macro To Generate Inline Assembly
Le Chaud Lapin <jaibud  2008-04-27 12:39:05 
Re: Macro To Generate Inline Assembly
Tony Delroy <tony_in_d  2008-04-28 02:13:23 
Re: Macro To Generate Inline Assembly
Le Chaud Lapin <jaibud  2008-04-28 16:06:49 
Re: Macro To Generate Inline Assembly
Mathias Gaunard <loufo  2008-04-28 20:34:54 
Re: Macro To Generate Inline Assembly
Le Chaud Lapin <jaibud  2008-04-28 23:23:12 
Re: Macro To Generate Inline Assembly
=?ISO-8859-1?Q?Daniel_Kr=  2008-04-29 10:35:49 
Re: Macro To Generate Inline Assembly
Francis Glassborow <fr  2008-04-29 10:43:23 
Re: Macro To Generate Inline Assembly
Le Chaud Lapin <jaibud  2008-04-29 17:38:48 
Re: Macro To Generate Inline Assembly
Le Chaud Lapin <jaibud  2008-04-29 17:42:22 
Re: Macro To Generate Inline Assembly
galathaea <galathaea@[  2008-04-29 18:29:42 
Re: Macro To Generate Inline Assembly
Carl Barron <cbarron41  2008-04-30 04:13:23 
Re: Macro To Generate Inline Assembly
Mathias Gaunard <loufo  2008-04-30 04:13:22 
Re: Macro To Generate Inline Assembly
Le Chaud Lapin <jaibud  2008-04-30 10:42:39 
Re: Macro To Generate Inline Assembly
John Nagle <nagle@[EMA  2008-05-03 06:13:27 
Re: Macro To Generate Inline Assembly
Le Chaud Lapin <jaibud  2008-05-03 16:10:43 
Re: Macro To Generate Inline Assembly
Le Chaud Lapin <jaibud  2008-05-03 16:13:24 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 2:42:28 CDT 2008.