Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the equivalent of _emit on Linux?

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?

like image 515
samgrover Avatar asked Apr 08 '09 19:04

samgrover


1 Answers

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

asm __volatile__ (".byte 0x12");

Although, you might get surprising results with optimizations enabled.

like image 190
zvrba Avatar answered Oct 12 '22 07:10

zvrba