LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Blogs
User Name
Password

Notices


Old

ASM: mixing assembler and C++

Posted 02-05-2012 at 12:05 PM by rainbowsally
Updated 08-06-2014 at 10:30 AM by rainbowsally

This is for intel 32 bit assembler. For 64-bits the calling convention is a bit different. See previous entries (specifically asm 64 bits) if you need a leg-up to break the 64 bit barrier.

Features:
  • Asm functions that can call class functions (using an object pointer) through jump vectors written in C.
  • Usage of extern "C" declarations to un-mangle names we need to keep simple for asm coding.

[If you really want to get down, you can use the mangled names as...
Member
Posted in Uncategorized
Views 1472 Comments 0 rainbowsally is offline
Old

ASM: Intercepting (and using) Errors (like segfaults) in asm (aka SEH)

Posted 02-03-2012 at 04:10 PM by rainbowsally

This is for i86 and x86_64 types but with a bit of poking around you can probably find a similar way to do this with other CPUs.

Note: This asm requires 'sigaction'. (See the test code. And bear in mind that this is not an attempt to create a full-blown system of signal handlers. Check the libc docs for 'sigaction' for ideas on how you can use something like this for a seed for a more extensive application.)

There used to be a lot of cool little programs for the...
Member
Posted in Uncategorized
Views 1534 Comments 0 rainbowsally is offline
Old

ASM: 64 bit intel asm in linux

Posted 02-03-2012 at 04:01 PM by rainbowsally

If you're used to 32 bit asm in gcc, the 64 bit asm might throw you for a loop initially. That's because part of the stack is passed around in registers.

Let's compile a bit of test code and see what's going on.

If you're using our makefile-creator put this in a subdirectory named "src" or use whatever method you prefer if not.

file: src/main.c
Code:
// main.c
#include <stdio.h>

void  dbg(){}
...
Member
Posted in Uncategorized
Views 1681 Comments 0 rainbowsally is offline
Old

Assembler Stuff: Asm and Inline Asm

Posted 01-25-2012 at 07:15 PM by rainbowsally

Assembler Stuff: Asm and Inline Asm

Features:
  • Asm and inline asm examples
  • Using C macros to create global function names
  • Intel and ATT syntax
  • Viewing disassembly in a *.s file and using objdump

Let's get right to the point...

Code:
// main.c
// COMPILE: gcc main.c -o main --save-temps
// take a look at the C asm output file, 'main.s' afterwar

// 64 bit asm keeps part of the stack in registers in C, so let's
//
...
Member
Posted in Uncategorized
Views 1302 Comments 0 rainbowsally is offline
Old

Simple C: Filling in the blanks - A simple memory allocator/reallocator.

Posted 01-23-2012 at 07:32 AM by rainbowsally

No memdup()? No memcat()? No prob.

Today's Features:
  • Simple C/C++ program and new memdup() and memcat() functions.
  • C macros (spanning lines with backslash) to create 'lenient' aliases.
  • Type casting in C/C++ to override sometimes overly strict syntax checks.
Anyone that has used strdup() or strcat() knows how convenient those are. But when it comes to memory allocation and reallocation for other kinds of data the lack of simple standard mechanisms for this often leads to duplicated...
Member
Posted in Uncategorized
Views 7028 Comments 1 rainbowsally is offline

  



All times are GMT -5. The time now is 10:56 PM.

Main Menu
Advertisement
Advertisement
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
Open Source Consulting | Domain Registration