This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
instruction-space modification
- From: "Gerard Visser" <visser dot gerard at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Mon, 15 Jan 2007 19:37:26 +0100
- Subject: instruction-space modification
Greeting,
I was wondering if you could help me with a problem. I can't seem to find an
answer anywhere.
When I try to alter data in instruction space in a c-programme, like:
call 0
pop bx
mov byte ptr [bx+7], 3
shl ax, 2
I get a "segmentation fault" because of the third instruction.
Could you tell me how to avoid this, or where I could find literature that
explains these kinds of questions.
I'm trying to do this, because "shl ax, cl" is not pairable and much slower
than a shift with an immediate constant second operand.
My test-programme looked like this:
int main() {
int a = 1;
asm(".byte 0xE8, 0x00, 0x00, 0x00, 0x00, 0x5B, 0xC6, 0x43;"
".byte 0x07, 0x03, 0xC1, 0xE0, 0x02;"
: "=a"(a)
: "a"(a)
: "%ebx", "%ecx", "%edx", "%esi", "%edi");
printf("%d\n",a); // Should produce "8"
return 0;
} // int main() endp
Kind regards,
Gerard Visser