hello world programm inline asm
-
hey i read this and wanted to make some simple try and stuck on first step...
just simple hello world i cant get adress of the char so i tried by db it doesnt work here my try:
so i cant use $msg herereally really shitti declaring char msg[] = "hello world"; and try $msg doesnt work too
maybe someone can help
i also assembled the programm and tried to vget adress of it by reading asm code but seg fault in here...int main ()
{
asm ("msg db 'Hello world',$0x0A\n\t"
"movl $4 ,%eax\n\t"
"movl $1 ,%ebx\n\t"
"movl $msg,%ecx\n\t"
"movl $len ,%edx\n\t"
"int $0x80 \n\t"
"movl $1,%eax \n\t "
"int $0x80"
);}
-
http://www.c-plusplus.net/forum/viewtopic-var-t-is-197875.html
bzw. der Link darin:
http://www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html
-
#include <stdio.h>
int main( void )
{
char test[] = "hello world";__asm__("movl $4, %%eax; movl $1, %%ebx\n"
"movl %0, %%ecx\n"
"movl $13, %%edx\n"
"int $0x80"
:: "m"(*test));
}This is still not working...
-
Hallo ich hab das mal geduggert und wenn ich %% benutze werden zb am anfang keine 4 zugewiesen sondern -14 ...
mit %%:
eax 0xfffffff2 -14mit %
eax 0x4 4
.
-
@someoneee: Und so funktioniert es bei mir:
tmp.c:int main(int argc, char* argv[]) { char test[] = "hello world\n"; argc = argc; argv = argv; __asm__ ( "movl $4, %%eax\n\t" "movl $1, %%ebx\n\t" "leal %0, %%ecx\n\t" "movl $12, %%edx\n\t" "int $0x80" :: "m"(*test)); return 0; }
gcc tmp.c -o tmp
Tipp: Schau dir die Assembler-Ausgabe des Compilers an!
gcc -S tmp.c
cat tmp.s
-
hi abc.w
danke nochmal nachträglich genau das habe ich gesucht