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 17 of 18 Topic 9553 of 9828
Post > Topic >>

Re: Macro To Generate Inline Assembly

by Le Chaud Lapin <jaibuduvin@[EMAIL PROTECTED] > May 3, 2008 at 04:10 PM

On Apr 27, 1:39 pm, Daniel Krügler <daniel.krueg...@[EMAIL PROTECTED]
>
wrote:
> On 27 Apr., 15:29, Le Chaud Lapin <jaibudu...@[EMAIL PROTECTED]
> wrote:
`> 1) IMO the x86 processor does not accept a literal
> as argument of mul (B == 0). Only registers or
> variables are allowed.

You're right. The example I gave was erroneous.

> 2) MS does not officially sup****t _asm, it seems
> to be a relict, which just may work. You will find
> out that it does *not* work, if you disable language
> extensions (/Za). I recommend to use the officially
> sup****ted __asm (double underscore) notation.

Fixed. :)

> > Naturally, I would like to understand not just how to do this for
> > VS2005, but for all systems/compilers, so that I am not left guessing
> > whether I got it right or not.
>
> Unfortunately this seems an impossible task, because
> no compiler I'm aware of uses the standardized syntax
> for assembler declaration, which would change your code to
>
> #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 I meant was to keep the interface seen by the pure C++ code the
same.

> Back to your compiler/pre-processor problem: It seems
> that you can solve your problem in this case by
> removing the final semicola (according to the MS
> do***entation this is feasible). My recommended
> syntax would be to write the code as follows (note
> that I use __asm instead of _asm):
>
> #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\
>
> }

Changes made.

Thanks for comments,

-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 Thu Jul 24 15:51:11 CDT 2008.