asm

J

Josh Lessard

Hey everyone...quick question for you.

I was under the impression that the `asm' command was not part of standard
C++ because all assembly language instructions are machine dependent.
However, I noticed that in the grammar appendix of Stroustrup, the `asm'
command is actually listed. I don't actually have a copy of the standard,
so I was just wondering:

Is the `asm' command actually part of standard C++??

*****************************************************
Josh Lessard
Master's Student
School of Computer Science
Faculty of Mathematics
University of Waterloo
(519)888-4567 x3400
http://www.cs.uwaterloo.ca
*****************************************************
 
G

Gianni Mariani

Josh said:
Hey everyone...quick question for you.

I was under the impression that the `asm' command was not part of standard
C++ because all assembly language instructions are machine dependent.
However, I noticed that in the grammar appendix of Stroustrup, the `asm'
command is actually listed. I don't actually have a copy of the standard,
so I was just wondering:

Is the `asm' command actually part of standard C++??

My guess is that it's part of the standard in that it is *reserved* for
use that is implementation specific. This requires conforming code to
not use the "asm" as a possible identifier - thus causing problems for
implementations that do support asm.
 
K

Kevin Goodsell

Josh said:
Hey everyone...quick question for you.

I was under the impression that the `asm' command was not part of standard
C++ because all assembly language instructions are machine dependent.
However, I noticed that in the grammar appendix of Stroustrup, the `asm'
command is actually listed. I don't actually have a copy of the standard,
so I was just wondering:

Is the `asm' command actually part of standard C++??

The 'asm' keyword is. 'Command' is not a term that has any meaning in
C++, as far as I know. Here's what the November 1997 draft of the
standard says about 'asm':

7.4 The asm declaration [dcl.asm]

1 An asm declaration has the form
asm-definition:
asm ( string-literal ) ;
The meaning of an asm declaration is implementation-defined. [Note:
Typically it is used to pass information through the implementation to
an assembler. ]
*****************************************************
Josh Lessard
Master's Student
School of Computer Science
Faculty of Mathematics
University of Waterloo
(519)888-4567 x3400
http://www.cs.uwaterloo.ca
*****************************************************

Do you think you could trim your sig to a reasonable length (4 lines or
so), and try to convince your news client to use a proper sig delimiter
(dash-dash-space)?

-Kevin
 
M

Mike Wahler

Josh Lessard said:
Hey everyone...quick question for you.

I was under the impression that the `asm' command was not part of standard
C++ because all assembly language instructions are machine dependent.
However, I noticed that in the grammar appendix of Stroustrup, the `asm'
command is actually listed. I don't actually have a copy of the standard,
so I was just wondering:

Is the `asm' command actually part of standard C++??

First note that C++ has no 'commands'.

Then let's look at the standard:

-----------------------------------------

ISO/IEC 14882:1998(E)

7.4 The asm declaration

1 An asm declaration has the form

asm­-definition:
asm ( string­-literal ) ;

The meaning of an asm declaration is implementation­-defined.
[Note: Typically it is used to pass informa­tion through the
implementation to an assembler. ]

-----------------------------------------

So the 'asm' keyword is indeed standard, but it's implementation
is necessarily platform/implementation-specific. This is similar
to the 'std::system()' function, which is standard, but whose
argument is platform/implementation-specific.

-Mike
 
E

E. Robert Tisdale

Josh said:
Hey everyone...quick question for you.

I was under the impression that the `asm' command was not part of standard
C++ because all assembly language instructions are machine dependent.
However, I noticed that in the grammar appendix of Stroustrup, the `asm'
command is actually listed. I don't actually have a copy of the standard,
so I was just wondering:

Is the `asm' command actually part of standard C++?

Yes. But that doesn't mean that
the assembler instructions themselves are portable.
 
J

Jonathan Turkanis

Mike Wahler said:
First note that C++ has no 'commands'.

Yeah, but it has plenty of directives, suggestions and hints. ;-)
Then let's look at the standard:

-----------------------------------------

ISO/IEC 14882:1998(E)

7.4 The asm declaration

1 An asm declaration has the form

asm­-definition:
asm ( string­-literal ) ;

The meaning of an asm declaration is implementation­-defined.
[Note: Typically it is used to pass informa­tion through the
implementation to an assembler. ]

For completeness, this language hasn't changed in the second edition.

Jonathan
 
J

Josh Lessard

First note that C++ has no 'commands'.

Yes I got called on that quite a few times. I'm actually well aware of
that fact...it was a poor choice of wording on my part.
Then let's look at the standard:

I really need to get myself a copy of the standard soon. ;)
So the 'asm' keyword is indeed standard, but it's implementation
is necessarily platform/implementation-specific. This is similar
to the 'std::system()' function, which is standard, but whose
argument is platform/implementation-specific.

Gotcha. Thanks a lot for your clarifications.

*****************************************************
Josh Lessard
M.Math Candidate
School of Computer Science
University of Waterloo (519)888-4567 x3400
http://www.cs.uwaterloo.ca
*****************************************************
 
M

Mike Wahler

E. Robert Tisdale said:
Dissembling?

Not at all. Only stating a fact.
Is C++ an imperative programming language or not?

You can call it that if you like. I simply call it
a useful, versatile, and powerful programming language.
In any case, it defines so such construct or concept
'imperative'.

-Mike
 
E

E. Robert Tisdale

Mike said:
You can call it that if you like. I simply call it
a useful, versatile, and powerful programming language.
In any case,
it defines so such construct or concept 'imperative'.

Does it need to?

1. The C++ computer programming language
is an *imperative* programming language.

2. The imperatives are the executable statements
in a C++ program.

3. The word 'command' is a synonym for 'imperative'.

The only reason that I can think of for preferring
the term 'executable statement' or even 'imperative'
over the term 'command' is so as not to confuse
executable statements with [UNIX] shell commands.

I suppose that I would prefer that you say,
"The term 'executable statement' is preferred over the term 'command'
so that they aren't confused with shell commands."
 
D

David Harmon

The only reason that I can think of for preferring
the term 'executable statement' or even 'imperative'
over the term 'command' is so as not to confuse
executable statements with [UNIX] shell commands.

Good enough reason. Or BASIC language commands, etc..

I think the reason to avoid referring to "commands" in C and C++ is to
remind the reader that the granularity is different than what he may be
used to. We have had people appear here asking about how to use the
"cout command". They won't make much progress until they get the
concept that std::cout is not a command.

Sure, there is no substantial difference between "executable statement"
and "command"; they designate the same set of things. But "executable
statement" rightly suggests that there are also non-executable ones,
namely declarations. This is an important point distinguishing C++
from UNIX shell or other languages where every line is a command.
 
E

E. Robert Tisdale

David said:
E. Robert Tisdale said:
The only reason that I can think of for preferring
the term 'executable statement' or even 'imperative'
over the term 'command' is so as not to confuse
executable statements with [UNIX] shell commands.


Good enough reason. Or BASIC language commands, etc..

I think the reason to avoid referring to "commands" in C and C++ is to
remind the reader that the granularity is different than what he may be
used to. We have had people appear here asking about how to use the
"cout command". They won't make much progress until they get the
concept that std::cout is not a command.

Sure, there is no substantial difference between "executable statement"
and "command"; they designate the same set of things. But "executable
statement" rightly suggests that there are also non-executable ones,
namely declarations. This is an important point distinguishing C++
from UNIX shell or other languages where every line is a command.

I agree.

int f(void) {
return 23;
}

int main(int argc, char* argv[]) {
int i = f();
return 0;
}

Do you consider the definition of int i to be an executable statement?
My inclination is to say that it is not.
 

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

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top