Re: How to move two valuables to x86 CPU register ebx, ecx by using AT&A inline asm.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thank you. I got error because the valuable I actually pass is a
member of structure point. ex.

       __asm__ volatile ("movl (%0), %%ebx\n"
         "movl (%1), %%ecx\n"
         : : "r"(ptr->cnt), "r"(ptr->blk) );

I reassigned ptr->cnt and ptr->blk to local unsigned int valuable and
compile successfully. BTW, the first ':' is mean output operands,
second ':' is mean input operands but how about third ':'. Does it
mean which registers had been changed in inline asm code? So, does gcc
do push and pop to retain these registers in the front and end of asm
code?
    I have tried to compile inline asm in user space application and
use gcc -S flag to translate c code to asm code. How do I translate
kernel driver to asm code without compile to obj file?

Thank your help
BR, H. Johnny

2009/11/19 Viral Mehta <viral.mehta@xxxxxxxxxxxxxx>:
> [root@viral temp_c_files]# gcc foo.c
> [root@viral temp_c_files]# cat foo.c
> #include <stdio.h>
> int main()
> {
>       unsigned int val = 10;
>       unsigned int tmp = 5;
>
>       __asm__ volatile ("movl (%0), %%ebx\n"
>         "movl (%1), %%ecx\n"
>         : : "r"(val), "r"(tmp) );
> }
>
> [root@viral temp_c_files]#
> Thanks,
> Viral Mehta,
> Embedded Software Engineer,
> Tel. No. 91 79 26563705, Ext. 423
> www.einfochips.com <http://www.einfochips.com>
> Prepare and Prevent rather than Repair and Repent
>
>
> Johnny Hung wrote:
>>
>> It doesn't works. :(
>>
>> 2009/11/19 Viral Mehta <viral.mehta@xxxxxxxxxxxxxx>:
>>
>>>
>>> How about putting \n at the end ?
>>>
>>> Just try out,
>>>
>>> __asm__ volatile ("movl %0, %%ebx\n"
>>>        "movl %1, %%ecx\n"
>>>
>>>
>>>
>>>
>>> Thanks,
>>> Viral Mehta,
>>> Embedded Software Engineer,
>>> Tel. No. 91 79 26563705, Ext. 423
>>> www.einfochips.com <http://www.einfochips.com>
>>> Prepare and Prevent rather than Repair and Repent
>>>
>>>
>>> Johnny Hung wrote:
>>>
>>>>
>>>> Hi All:
>>>>   I want to move two local valuables to x86 arch CPU ebx, ecx
>>>> register and do outb cpu instruction by using AT&A inline asm in
>>>> kernel driver.  The following code was I wrote but gcc report syntax
>>>> error:
>>>> ==
>>>>   unsigned int val = 10;
>>>>   unsigned int tmp = 5;
>>>>   ....
>>>>   __asm__ volatile ("movl %0, %%ebx"
>>>>         "movl %1, %%ecx"
>>>>         "outb $0x27, $0xb2"
>>>>         :
>>>>         :"r"(val), "r"(tmp)
>>>>         :"%ebx", "%ecx"
>>>>  );
>>>>
>>>> Does anyone can point me out. Any reply is appreciated.
>>>>
>>>> BRs, H. Johnny
>>>>
>>>> --
>>>> To unsubscribe from this list: send an email with
>>>> "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
>>>> Please read the FAQ at http://kernelnewbies.org/FAQ
>>>>
>>>>
>>>>
>>>> Email Scanned for Virus & Dangerous Content by :
>>>> www.CleanMailGateway.com
>>>>
>>>>
>>>>
>>>>
>>>
>>> --
>>> _____________________________________________________________________
>>> Disclaimer: This e-mail message and all attachments transmitted with it
>>> are intended solely for the use of the addressee and may contain legally
>>> privileged and confidential information. If the reader of this message
>>> is not the intended recipient, or an employee or agent responsible for
>>> delivering this message to the intended recipient, you are hereby
>>> notified that any dissemination, distribution, copying, or other use of
>>> this message or its attachments is strictly prohibited. If you have
>>> received this message in error, please notify the sender immediately by
>>> replying to this message and please delete it from your computer. Any
>>> views expressed in this message are those of the individual sender
>>> unless otherwise stated.Company has taken enough precautions to prevent
>>> the spread of viruses. However the company accepts no liability for any
>>> damage caused by any virus transmitted by this email.
>>> _____________________________________________________________________
>>>
>>>
>>>
>>
>>
>> Email Scanned for Virus & Dangerous Content by : www.CleanMailGateway.com
>>
>>
>>
>
> --
> _____________________________________________________________________
> Disclaimer: This e-mail message and all attachments transmitted with it
> are intended solely for the use of the addressee and may contain legally
> privileged and confidential information. If the reader of this message
> is not the intended recipient, or an employee or agent responsible for
> delivering this message to the intended recipient, you are hereby
> notified that any dissemination, distribution, copying, or other use of
> this message or its attachments is strictly prohibited. If you have
> received this message in error, please notify the sender immediately by
> replying to this message and please delete it from your computer. Any
> views expressed in this message are those of the individual sender
> unless otherwise stated.Company has taken enough precautions to prevent
> the spread of viruses. However the company accepts no liability for any
> damage caused by any virus transmitted by this email.
> _____________________________________________________________________
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-embedded" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Gstreamer Embedded]     [Linux MMC Devel]     [U-Boot V2]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux ARM Kernel]     [Linux OMAP]     [Linux SCSI]

  Powered by Linux