This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Add assembly instruction to GCC
- From: Amir Ghanbari <a dot ghanbari1990 at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 12 Apr 2012 19:39:07 -0400
- Subject: Add assembly instruction to GCC
Hello all,
I'm trying to expand X86 ISA. So I have added some hardware to X86 (in
Gem5 Simulator) and I have updated X86 decoder to support those
instructions. In order to call those instructions I use GCC inline
assembly ".byte" directive. something like this : ".byte 0xF0, 0x0F,
0x23;"
The problem is when I compile my code using GCC, it changes the
instructions that i have created. For instance:
I intend to have something generated like this:
?403ce3: 48 89 eb ? ? ? ? ? ? mov ? ?%rbp,%rbx
?403ce6: 48 83 e3 fe ? ? ? ? ? and ? ?$0xfffffffffffffffe,%rbx
?403cea: 48 8b 7c 24 08 ? ? ?mov ? ?0x8(%rsp),%rdi
?403cef: f0 0f 23 ? ? ? ? ? ? lock (bad)
?403cf2: 48 89 04 24 ? ? ? ? ? mov ? ?%rax,(%rsp)
?403cf6: 4c 8b 34 24 ? ? ? ? ? mov ? ?(%rsp),%r14
but GCC generates something like this:
?403ce3: 48 89 eb ? ? ? ? ? ? mov ? ?%rbp,%rbx
?403ce6: 48 83 e3 fe ? ? ? ? ? and ? ?$0xfffffffffffffffe,%rbx
?403cea: 48 8b 7c 24 08 ? ? mov ? ?0x8(%rsp),%rdi
?403cef: f0 0f ? ? ? ? ? ? ? ? ? ? lock mov (bad),%db1 ? ?====> GCC
screws up this part
?403cf1: 23 48 89 ? ? ? ? ? ? and ? ?-0x77(%rax),%ecx ?==> and this
?403cf4: 04 24 ? ? ? ? ? ? ? ? add ? ?$0x24,%al ? ? ? ? ====> and this
?403cf6: 4c 8b 34 24 ? ? ? ? ? mov ? ?(%rsp),%r14
Is there a way to tell GCC that "F0 0F 23" is a unique instruction so
it wouldn't mix it with other instructions?
Thank you,
--
Amir