views:

344

answers:

1

I'm trying to port some assembly code written in Visual Studio into GNU inline assembly on Linux. The original code uses _emit which MSDN describes as a pseudo instruction and explains as:

The _emit pseudoinstruction is similar to the DB directive of MASM. You use _emit to define a single immediate byte at the current location in the current text segment. However, _emit can define only one byte at a time, and it can only define bytes in the text segment. It uses the same syntax as the INT instruction.

How can I do the same thing on Linux?

+4  A: 

To emit byte 0x12 (for example), do:

asm __volatile__ (".byte 0x12");

Although, you might get surprising results with optimizations enabled.

zvrba
+1, good point about optimizations.
Adam Rosenfield
Thanks! This worked out well.
samgrover