Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 02-04-2012, 05:10 PM   #1
Registered: Oct 2011
Posts: 47
Blog Entries: 138

Rep: Reputation: Disabled
inline asm, 64-bit asm, intercepting segfaults, etc.

This isn't a question, per se, but it addresses some questions I had that I couldn't find answered anywhere in the inhabited universe.

I've posted some examples of inline assembly, some macros for defining global functions, how to look up the "context" after a segfault and keep running (displays the kind of memory: read-only, read-write, inaccessible without crashing), and some other stuff.

Mostly fairly simple and written in the gcc dialect, but shows how to write and get disassembly for intel syntax as well.

Should be helpful for anyone interested in assembler, especially AT&T syntax inlined in C/C++ programs. (The asm to C++ interfacing isn't written yet but you can call the C++ through a cdecl intermediary easily enough.)

The code and macros and even the psig_context struct example might provide clues about how to do this stuff for other cpus, though I concentrate on intel 32 and 64 bit thingies.

Here are the three currently existing blog entries on the subject.

Assembler Stuff: Asm and Inline Asm
Macros to simplify definitions of functions inlined in a dummy code section within a simple C function and looks at the intermediate gcc asm output file for the function and all the rest of the C output.

ASM: 64 bit intel asm in linux
Shows what happens on the stack in 64 bit calls.

The demo code for this one is pretty interesting. :-) Give it a whirl if you've got a sec.
ASM: Intercepting (and using) Errors (like segfaults) in asm (aka SEH)
The demo uses segfaults programmatically (not try/catch) to set a flag showing the type of memory accesses available.


Last edited by rainbowsally; 02-04-2012 at 05:15 PM. Reason: bold link titles for contrast


asm, exception, handling, inline, intel

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ASM or C++? Hb_Kai Programming 16 01-20-2010 09:12 AM
gcc inline asm question vv40in Programming 0 04-17-2009 03:37 AM
ASM x32 vs ASM x64 Tegramon Programming 3 02-27-2008 02:26 PM
I/O in ASM Mercurius Programming 10 11-16-2006 07:02 PM
Jumping in asm LongName Programming 3 08-31-2004 07:27 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:20 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration