Asm programming capability?

D

deostroll

does the c++ standard say anything about being able to write inline
assembly instructions. Is it a must for any c++ compiler?

--deostroll
 
V

Victor Bazarov

deostroll said:
does the c++ standard say anything about being able to write inline
assembly instructions. Is it a must for any c++ compiler?

Yes, it's a declaration, and the form is

asm ( string-literal ) ;

The interpretation of the string-literal is compiler-specific.

V
 
B

Bo Persson

Victor said:
Yes, it's a declaration, and the form is

asm ( string-literal ) ;

The interpretation of the string-literal is compiler-specific.

Unfortunately, some compiler-specific documentations say "does not
work".

And when it does work, the format of the string literal is extremenly
non-portable.


Bo Persson
 
V

Victor Bazarov

Bo said:
Unfortunately, some compiler-specific documentations say "does not
work".

And when it does work, the format of the string literal is extremenly
non-portable.
^^^^^^^^^^^^
I believe that's what "compiler-specific" means.

To the OP: also look at compiler-specific ways to embed the assembly.
For example, some compilers offer the

__asm {
instructions
}

blocks...

V
 
J

James Kanze

Unfortunately, some compiler-specific documentations say "does
not work".
And when it does work, the format of the string literal is
extremenly non-portable.

That's rather obvious, isn't it? Assembler is by definition
non-portable. And the standard does say that the interpretation
of the string is "implementation defined"; an implementation in
which all strings result in an error is fully conform, provided
that the implementation documents it.

Note that some compilers don't take this too literally, or
extend it in various ways. In g++, for example, you can add
various "constraints" after the string literal, to cause the
compiler to map arguments to arbitrary C++ expressions.
Technically, I suppose that this is non-conformant, but I can't
see where it could matter; since the string literal is already
implementation defined, replacing it with something slightly
more complex isn't going to break compatibility any more than it
is already broken.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Asm programming capability? 21
Bare metal. 0
New Programming Language GALAXION 2
What is Programming? 4
Text File Only Programming 1
Programming with an old Mac OS 10.11.6 1
Looking For Advice 1
Login to MYSQL 1

Members online

Forum statistics

Threads
474,159
Messages
2,570,881
Members
47,418
Latest member
NoellaXku

Latest Threads

Top