C inline assembly

Source: Internet
Author: User

Compilation can make the program more efficient, but it should be used only when there is interaction with the hardware, so you know the basic syntax.

_ ASM _ volatile __(

"Movl % 1, % eax" // There is no \ n \ t direct semicolon in the book, and there has been an error in compilation,
"Movl % 2, % EBX"
"Movl % eax, % 0"
: "= R" (REG)

: "R" (CE), "R" (EE ))

The following code is from the Linux kernel programming, But I directly compiled an error in the book,

# Include <stdio. h>
# Include <string. h>
# Include <stdlib. h>
 
Int fun ()
{
Int EE = 0X4000, Ce = 0 x8000, reg;
 
_ ASM _ volatile __(
"Movl % 1, % eax \ n \ t"
"Movl % 2, % EBX \ n \ t"
"Movl % eax, % 0 \ n \ t"
: "= R" (REG)
: "R" (CE), "R" (EE)
: "% Eax", "% EBX ");
 
Printf ("Reg = % x", Reg );
Return 0;
}
 

Welcome to my blog: http://www.fuxiang90.me /? P = 708

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.