LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

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

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
http://www.linuxquestions.org/questi...ine-asm-34412/
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
http://www.linuxquestions.org/questi...n-linux-34435/
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)
http://www.linuxquestions.org/questi...aka-seh-34436/
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
 
  


Reply

Tags
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


All times are GMT -5. The time now is 02:18 AM.

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