Two forms of inline-assembly [duplicate]
This question already has an answer here:
What is the difference between 'asm', '__asm' and '__asm__'?
4 answers
There are two forms of inline assembly, one is
asm{
//...
}
the other
asm(
"..."//work in my clang compiler
);
and __asm and so on, so what is the difference?
definitely not just about curly braces and brackets, i hope
c assembly language-lawyer inline-assembly
marked as duplicate by Peter Cordes
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 17:10
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
|
show 7 more comments
This question already has an answer here:
What is the difference between 'asm', '__asm' and '__asm__'?
4 answers
There are two forms of inline assembly, one is
asm{
//...
}
the other
asm(
"..."//work in my clang compiler
);
and __asm and so on, so what is the difference?
definitely not just about curly braces and brackets, i hope
c assembly language-lawyer inline-assembly
marked as duplicate by Peter Cordes
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 17:10
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
That's the great thing about standards: there are so many to choose from.
– Bathsheba
Nov 21 '18 at 11:56
1
The first kind is MSVC style inline assembly while the second one is gcc style inline assembly. Entirely different approaches, the second one is usually superior for the situations where you'd use inline assembly in production code today.
– fuz
Nov 21 '18 at 12:06
2
@Lundin if one compiler gives you hammer, and other gives you toolbox (including hammer), then the other is superior. (which is basically the analogy to MSCC inline asm vs gcc/clang inline asm) ... also you basically shouldn't use either, unless you really know what you are doing: gcc.gnu.org/wiki/DontUseInlineAsm
– Ped7g
Nov 21 '18 at 12:46
1
@Ped7g These aren't the only forms, as there's more to programming than your PC. There's also hammers with wooden shafts, hammers with metal shaft, hammers with metal shaft + rubber for handle, hammers that can remove nails etc etc. Now, what I would like is a standardized saw. Which one of these hammer types is best for sawing?
– Lundin
Nov 21 '18 at 13:02
1
@Caleb I don't quite feel like making an answer right now, but gcc-style syntax is superior because it allows the programmer to specify a lot of metadata the compiler can use for optimisations. Also, gcc-style syntax allows the compiler to place variables in registers which isn't possible with MSVC-style assemble. While the latter might be a bit more user-friendly, it is pretty much obsolete with today's reasons why people write inline assembly at all.
– fuz
Nov 21 '18 at 17:44
|
show 7 more comments
This question already has an answer here:
What is the difference between 'asm', '__asm' and '__asm__'?
4 answers
There are two forms of inline assembly, one is
asm{
//...
}
the other
asm(
"..."//work in my clang compiler
);
and __asm and so on, so what is the difference?
definitely not just about curly braces and brackets, i hope
c assembly language-lawyer inline-assembly
This question already has an answer here:
What is the difference between 'asm', '__asm' and '__asm__'?
4 answers
There are two forms of inline assembly, one is
asm{
//...
}
the other
asm(
"..."//work in my clang compiler
);
and __asm and so on, so what is the difference?
definitely not just about curly braces and brackets, i hope
This question already has an answer here:
What is the difference between 'asm', '__asm' and '__asm__'?
4 answers
c assembly language-lawyer inline-assembly
c assembly language-lawyer inline-assembly
edited Nov 21 '18 at 12:09
Bathsheba
176k27251373
176k27251373
asked Nov 21 '18 at 11:55
bright yangbright yang
243
243
marked as duplicate by Peter Cordes
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 17:10
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Peter Cordes
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 21 '18 at 17:10
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
That's the great thing about standards: there are so many to choose from.
– Bathsheba
Nov 21 '18 at 11:56
1
The first kind is MSVC style inline assembly while the second one is gcc style inline assembly. Entirely different approaches, the second one is usually superior for the situations where you'd use inline assembly in production code today.
– fuz
Nov 21 '18 at 12:06
2
@Lundin if one compiler gives you hammer, and other gives you toolbox (including hammer), then the other is superior. (which is basically the analogy to MSCC inline asm vs gcc/clang inline asm) ... also you basically shouldn't use either, unless you really know what you are doing: gcc.gnu.org/wiki/DontUseInlineAsm
– Ped7g
Nov 21 '18 at 12:46
1
@Ped7g These aren't the only forms, as there's more to programming than your PC. There's also hammers with wooden shafts, hammers with metal shaft, hammers with metal shaft + rubber for handle, hammers that can remove nails etc etc. Now, what I would like is a standardized saw. Which one of these hammer types is best for sawing?
– Lundin
Nov 21 '18 at 13:02
1
@Caleb I don't quite feel like making an answer right now, but gcc-style syntax is superior because it allows the programmer to specify a lot of metadata the compiler can use for optimisations. Also, gcc-style syntax allows the compiler to place variables in registers which isn't possible with MSVC-style assemble. While the latter might be a bit more user-friendly, it is pretty much obsolete with today's reasons why people write inline assembly at all.
– fuz
Nov 21 '18 at 17:44
|
show 7 more comments
That's the great thing about standards: there are so many to choose from.
– Bathsheba
Nov 21 '18 at 11:56
1
The first kind is MSVC style inline assembly while the second one is gcc style inline assembly. Entirely different approaches, the second one is usually superior for the situations where you'd use inline assembly in production code today.
– fuz
Nov 21 '18 at 12:06
2
@Lundin if one compiler gives you hammer, and other gives you toolbox (including hammer), then the other is superior. (which is basically the analogy to MSCC inline asm vs gcc/clang inline asm) ... also you basically shouldn't use either, unless you really know what you are doing: gcc.gnu.org/wiki/DontUseInlineAsm
– Ped7g
Nov 21 '18 at 12:46
1
@Ped7g These aren't the only forms, as there's more to programming than your PC. There's also hammers with wooden shafts, hammers with metal shaft, hammers with metal shaft + rubber for handle, hammers that can remove nails etc etc. Now, what I would like is a standardized saw. Which one of these hammer types is best for sawing?
– Lundin
Nov 21 '18 at 13:02
1
@Caleb I don't quite feel like making an answer right now, but gcc-style syntax is superior because it allows the programmer to specify a lot of metadata the compiler can use for optimisations. Also, gcc-style syntax allows the compiler to place variables in registers which isn't possible with MSVC-style assemble. While the latter might be a bit more user-friendly, it is pretty much obsolete with today's reasons why people write inline assembly at all.
– fuz
Nov 21 '18 at 17:44
That's the great thing about standards: there are so many to choose from.
– Bathsheba
Nov 21 '18 at 11:56
That's the great thing about standards: there are so many to choose from.
– Bathsheba
Nov 21 '18 at 11:56
1
1
The first kind is MSVC style inline assembly while the second one is gcc style inline assembly. Entirely different approaches, the second one is usually superior for the situations where you'd use inline assembly in production code today.
– fuz
Nov 21 '18 at 12:06
The first kind is MSVC style inline assembly while the second one is gcc style inline assembly. Entirely different approaches, the second one is usually superior for the situations where you'd use inline assembly in production code today.
– fuz
Nov 21 '18 at 12:06
2
2
@Lundin if one compiler gives you hammer, and other gives you toolbox (including hammer), then the other is superior. (which is basically the analogy to MSCC inline asm vs gcc/clang inline asm) ... also you basically shouldn't use either, unless you really know what you are doing: gcc.gnu.org/wiki/DontUseInlineAsm
– Ped7g
Nov 21 '18 at 12:46
@Lundin if one compiler gives you hammer, and other gives you toolbox (including hammer), then the other is superior. (which is basically the analogy to MSCC inline asm vs gcc/clang inline asm) ... also you basically shouldn't use either, unless you really know what you are doing: gcc.gnu.org/wiki/DontUseInlineAsm
– Ped7g
Nov 21 '18 at 12:46
1
1
@Ped7g These aren't the only forms, as there's more to programming than your PC. There's also hammers with wooden shafts, hammers with metal shaft, hammers with metal shaft + rubber for handle, hammers that can remove nails etc etc. Now, what I would like is a standardized saw. Which one of these hammer types is best for sawing?
– Lundin
Nov 21 '18 at 13:02
@Ped7g These aren't the only forms, as there's more to programming than your PC. There's also hammers with wooden shafts, hammers with metal shaft, hammers with metal shaft + rubber for handle, hammers that can remove nails etc etc. Now, what I would like is a standardized saw. Which one of these hammer types is best for sawing?
– Lundin
Nov 21 '18 at 13:02
1
1
@Caleb I don't quite feel like making an answer right now, but gcc-style syntax is superior because it allows the programmer to specify a lot of metadata the compiler can use for optimisations. Also, gcc-style syntax allows the compiler to place variables in registers which isn't possible with MSVC-style assemble. While the latter might be a bit more user-friendly, it is pretty much obsolete with today's reasons why people write inline assembly at all.
– fuz
Nov 21 '18 at 17:44
@Caleb I don't quite feel like making an answer right now, but gcc-style syntax is superior because it allows the programmer to specify a lot of metadata the compiler can use for optimisations. Also, gcc-style syntax allows the compiler to place variables in registers which isn't possible with MSVC-style assemble. While the latter might be a bit more user-friendly, it is pretty much obsolete with today's reasons why people write inline assembly at all.
– fuz
Nov 21 '18 at 17:44
|
show 7 more comments
2 Answers
2
active
oldest
votes
The C language does not support inline assembler, so either form is non-standard. Every compiler tends to do this differently and therefore the syntax will vary.
Some compilers use double underscore __
to let through all non-standard keywords even when compiling in C standard mode.
Unlike C, C++ does support it through standardization, in the form of asm("instruction");
.
add a comment |
Annex J of the C standard is informative and states that if asm
is supported (and it doesn't have to be), then it ought to be of the form
asm ( character-string-literal );
In other words, the notation using the braces is arguably less conventional than the one using the parentheses.
(The requirements in C++ are stronger.)
C does't supportasm
. Annex J is not normative and it only gives an example of the most common form of non-standard extensions - the same one as standardized by C++.
– Lundin
Nov 21 '18 at 12:12
1
J.5.10 says "The most common implementation is via a statement of the form asm(...)" How do you read it to say that it must be of this form, or that any other form isn't standard?
– Paul Hankin
Nov 21 '18 at 12:19
1
@PaulHankin The key is C11 p554: "Annex J (informative)". Nothing in that annex contains language requirements, it is just extra information.
– Lundin
Nov 21 '18 at 12:21
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The C language does not support inline assembler, so either form is non-standard. Every compiler tends to do this differently and therefore the syntax will vary.
Some compilers use double underscore __
to let through all non-standard keywords even when compiling in C standard mode.
Unlike C, C++ does support it through standardization, in the form of asm("instruction");
.
add a comment |
The C language does not support inline assembler, so either form is non-standard. Every compiler tends to do this differently and therefore the syntax will vary.
Some compilers use double underscore __
to let through all non-standard keywords even when compiling in C standard mode.
Unlike C, C++ does support it through standardization, in the form of asm("instruction");
.
add a comment |
The C language does not support inline assembler, so either form is non-standard. Every compiler tends to do this differently and therefore the syntax will vary.
Some compilers use double underscore __
to let through all non-standard keywords even when compiling in C standard mode.
Unlike C, C++ does support it through standardization, in the form of asm("instruction");
.
The C language does not support inline assembler, so either form is non-standard. Every compiler tends to do this differently and therefore the syntax will vary.
Some compilers use double underscore __
to let through all non-standard keywords even when compiling in C standard mode.
Unlike C, C++ does support it through standardization, in the form of asm("instruction");
.
answered Nov 21 '18 at 12:12
LundinLundin
107k17158262
107k17158262
add a comment |
add a comment |
Annex J of the C standard is informative and states that if asm
is supported (and it doesn't have to be), then it ought to be of the form
asm ( character-string-literal );
In other words, the notation using the braces is arguably less conventional than the one using the parentheses.
(The requirements in C++ are stronger.)
C does't supportasm
. Annex J is not normative and it only gives an example of the most common form of non-standard extensions - the same one as standardized by C++.
– Lundin
Nov 21 '18 at 12:12
1
J.5.10 says "The most common implementation is via a statement of the form asm(...)" How do you read it to say that it must be of this form, or that any other form isn't standard?
– Paul Hankin
Nov 21 '18 at 12:19
1
@PaulHankin The key is C11 p554: "Annex J (informative)". Nothing in that annex contains language requirements, it is just extra information.
– Lundin
Nov 21 '18 at 12:21
add a comment |
Annex J of the C standard is informative and states that if asm
is supported (and it doesn't have to be), then it ought to be of the form
asm ( character-string-literal );
In other words, the notation using the braces is arguably less conventional than the one using the parentheses.
(The requirements in C++ are stronger.)
C does't supportasm
. Annex J is not normative and it only gives an example of the most common form of non-standard extensions - the same one as standardized by C++.
– Lundin
Nov 21 '18 at 12:12
1
J.5.10 says "The most common implementation is via a statement of the form asm(...)" How do you read it to say that it must be of this form, or that any other form isn't standard?
– Paul Hankin
Nov 21 '18 at 12:19
1
@PaulHankin The key is C11 p554: "Annex J (informative)". Nothing in that annex contains language requirements, it is just extra information.
– Lundin
Nov 21 '18 at 12:21
add a comment |
Annex J of the C standard is informative and states that if asm
is supported (and it doesn't have to be), then it ought to be of the form
asm ( character-string-literal );
In other words, the notation using the braces is arguably less conventional than the one using the parentheses.
(The requirements in C++ are stronger.)
Annex J of the C standard is informative and states that if asm
is supported (and it doesn't have to be), then it ought to be of the form
asm ( character-string-literal );
In other words, the notation using the braces is arguably less conventional than the one using the parentheses.
(The requirements in C++ are stronger.)
edited Nov 21 '18 at 12:23
answered Nov 21 '18 at 12:08
BathshebaBathsheba
176k27251373
176k27251373
C does't supportasm
. Annex J is not normative and it only gives an example of the most common form of non-standard extensions - the same one as standardized by C++.
– Lundin
Nov 21 '18 at 12:12
1
J.5.10 says "The most common implementation is via a statement of the form asm(...)" How do you read it to say that it must be of this form, or that any other form isn't standard?
– Paul Hankin
Nov 21 '18 at 12:19
1
@PaulHankin The key is C11 p554: "Annex J (informative)". Nothing in that annex contains language requirements, it is just extra information.
– Lundin
Nov 21 '18 at 12:21
add a comment |
C does't supportasm
. Annex J is not normative and it only gives an example of the most common form of non-standard extensions - the same one as standardized by C++.
– Lundin
Nov 21 '18 at 12:12
1
J.5.10 says "The most common implementation is via a statement of the form asm(...)" How do you read it to say that it must be of this form, or that any other form isn't standard?
– Paul Hankin
Nov 21 '18 at 12:19
1
@PaulHankin The key is C11 p554: "Annex J (informative)". Nothing in that annex contains language requirements, it is just extra information.
– Lundin
Nov 21 '18 at 12:21
C does't support
asm
. Annex J is not normative and it only gives an example of the most common form of non-standard extensions - the same one as standardized by C++.– Lundin
Nov 21 '18 at 12:12
C does't support
asm
. Annex J is not normative and it only gives an example of the most common form of non-standard extensions - the same one as standardized by C++.– Lundin
Nov 21 '18 at 12:12
1
1
J.5.10 says "The most common implementation is via a statement of the form asm(...)" How do you read it to say that it must be of this form, or that any other form isn't standard?
– Paul Hankin
Nov 21 '18 at 12:19
J.5.10 says "The most common implementation is via a statement of the form asm(...)" How do you read it to say that it must be of this form, or that any other form isn't standard?
– Paul Hankin
Nov 21 '18 at 12:19
1
1
@PaulHankin The key is C11 p554: "Annex J (informative)". Nothing in that annex contains language requirements, it is just extra information.
– Lundin
Nov 21 '18 at 12:21
@PaulHankin The key is C11 p554: "Annex J (informative)". Nothing in that annex contains language requirements, it is just extra information.
– Lundin
Nov 21 '18 at 12:21
add a comment |
That's the great thing about standards: there are so many to choose from.
– Bathsheba
Nov 21 '18 at 11:56
1
The first kind is MSVC style inline assembly while the second one is gcc style inline assembly. Entirely different approaches, the second one is usually superior for the situations where you'd use inline assembly in production code today.
– fuz
Nov 21 '18 at 12:06
2
@Lundin if one compiler gives you hammer, and other gives you toolbox (including hammer), then the other is superior. (which is basically the analogy to MSCC inline asm vs gcc/clang inline asm) ... also you basically shouldn't use either, unless you really know what you are doing: gcc.gnu.org/wiki/DontUseInlineAsm
– Ped7g
Nov 21 '18 at 12:46
1
@Ped7g These aren't the only forms, as there's more to programming than your PC. There's also hammers with wooden shafts, hammers with metal shaft, hammers with metal shaft + rubber for handle, hammers that can remove nails etc etc. Now, what I would like is a standardized saw. Which one of these hammer types is best for sawing?
– Lundin
Nov 21 '18 at 13:02
1
@Caleb I don't quite feel like making an answer right now, but gcc-style syntax is superior because it allows the programmer to specify a lot of metadata the compiler can use for optimisations. Also, gcc-style syntax allows the compiler to place variables in registers which isn't possible with MSVC-style assemble. While the latter might be a bit more user-friendly, it is pretty much obsolete with today's reasons why people write inline assembly at all.
– fuz
Nov 21 '18 at 17:44