- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can I use labels in inline assembly such as this:
int main()
{
__asm__(
"jmp label_1;"
);
label_1:
return 0;
}
Mine doesn't seem to compile somehow...
Link Copied
- « Previous
-
- 1
- 2
- Next »
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sergey Kostrov wrote:
It was already explained by Elbert that Intel C++ compiler version 2013 integrated with VS 2012 under Windows was actually used. Even if initial test-case created some confusion I don't think that Elbert is interested in Linux, GCC and AT&T style of inline assembler. Elbert, am I correct?
Sergey,
I realized from the beginning that the windows compiler was being used and had no intentions of having someone switch platforms. I posted my test case (which works) purely to contribute to the thread. It was not until Jim's followup post to me that I did some digging and learned that the handling of inline assembly is different between windows and linux, making the test case platform specific -- knowledge of which I also contributed to this thread. There aren't too many issues where the platform is going to matter but this indeed is one of them. BTW, I never mentioned GCC in my post, my test case compiles against Intel's icc (Which you can see in my post), though the __asm__ is assembled behind the scenes by a GNU assembler, this is not something you interact with directly. I also acknowledge that it was *my* test case that caused confusion since I posted something that met the OP's requirements but (unknowingly) did not work on his platform. I'll also reiterate that the AT&T style assembler was produced by icc and only posted to show that correct assembly was produced from the test case -- it does not matter what format it is in for that confirmation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you everyone for the posts. It is of great help to me. I've been doing assembly for quite some time using LLVM on OS X and have been acquainted using AT&T style of assembly. I am recently studying inline assembly in windows through visual studio for a project and saw intel compiler supports AT&T style, which I believe will make things quite easier for me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sergey Kostrov wrote:
Some issues related to the subject of the thread are dated back to 2004 year. This is what I found in Release Notes for Intel C++ compiler version 7.1 Update 29:
...
In an inline asm block, the conditional jumps, jcxz and jecxz, should
not be used to jump to another function. For instance, jcxz and jecxz
will not have the correct target location in the following code:
This makes sense to me. If it were implemented, only the C code would work. But in C++ compiler generates code for calling destructors of instances of non-POD classes/structs allocated on the stack, and even in C the stack needs to be rolled back. The only exception are C++ exceptions that work accross function calls, but compiler takes care of it and knows about this "nearly non-standard" event (the throw), unlike event of jump into another function, about which compiler knows nothing. This technique could corrupt stack and lead to program unstability. Though, it is possible to do this without corrupting the stack, but this is what I call a big no-no and a bad coding practice.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- « Previous
-
- 1
- 2
- Next »