Re: [LIP] syscall simulation!

sanjay panchal <sanjay_pec-/[email protected]>
Newsgroups gmane.user-groups.linux.india.programmers
Message-ID <[email protected]>
hey arun,
> 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)
>     );

I tried my code with the modified constraint "m"
instead of "g" (xor's removed) and found that it
worked properly,
see the code below
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 %0,%%ecx\n\t"
         "movl $12,%%edx\n\t"     /*strlength*/
         "int $0x80\n\t"
         :: "m" (hello)
    );
        printf("\n");
}
but,while compiling, gcc gave a warning
warning: use of memory input without lvalue in asm
operand 0 is deprecated (why??)

Refering to ur code, isn't specifying constraint "c"
(ie use ecx to hold a variable) same as moving
argument %0 into ecx (which I was doing explicitly by
using constraint "g") ? 

What exactly is happening when we are executing
movl %0,%%ecx 
Is it moving the memory location of "hello world\n"
using  disp(base,index,scale)?

-sanjay



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


-------------------------------------------------------
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.