Re: [LIP] syscall simulation!

Arun Sharma <[email protected]>
Newsgroups gmane.user-groups.linux.india.programmers
Message-ID <[email protected]>
On Thu, Feb 17, 2005 at 08:01:24PM -0800, sanjay panchal wrote:
> Here's the code snippet. 
> main()
> {
>     char hello[]="hello world\n";
>     __asm__ __volatile(
>          "xorl %%eax,%%eax\n\t"
>          "movl $4,%%eax\n\t"      /*$4 SYS_write*/    
>          "xorl %%ebx,%%ebx\n\t"
>          "movl $1,%%ebx\n\t"      /*$1 fd for stdout*/
>          "movl %0,%%ecx\n\t"      /*string */ 
>          "movl $12,%%edx\n\t"     /*strlength*/
>          "int $0x80\n\t"
>          ::"g" (hello)
>     );
>         printf("\n");
> }

Your xors are superfluous and the real issue is that ecx is 0 when you call
int 0x80. Try:

main()
{
    char hello[]="hello world\n";
    __asm__ __volatile(
         "movl $4,%%eax\n\t"      /*$4 SYS_write*/
         "movl $1,%%ebx\n\t"      /*$1 fd for stdout*/
         "movl $12,%%edx\n\t"     /*strlength*/
         "int $0x80\n\t"
         :: "c" (hello)
    );
        printf("\n");
}

	-Arun


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.