Linux kernel source code scenario analysis (3)-assembly language in Linux Kernel

Source: Internet
Author: User

1. The Code in the underlying Linux kernel is mostly completed in assembly language.
assembly code exists in two forms. One is a pure assembly code file suffixed with. S. Of course, the precompilation option is also added to such assembly code, rather than just assembly. The other is to embed the assembly language in the C language. Although there are no provisions on Assembly fragments in ansi c language standards, in fact, all the actually used C compilations have been expanded in this regard. The gnu c compiler GCC has also made great extensions in this regard.
the gnu c compiler GCC uses different syntaxes than the commonly used 386 assembly language in the kernel "pure" assembly code; in the Assembly snippet embedded in the C Program , it also adds a number of language components that guide assembly tools on how to allocate registers and how to combine variables defined in C Programs. these components make this assembly language actually an intermediate language between 386 assembly and C.

2. assembly Language embedded in C Code
the assembly language segments inserted into C code can be divided into four parts, separated by, the general format is
command department: Output Department: Input department: department of damage
where the command department is required, the format is roughly the same as that of standard assembly.
output indicates the association between the assembly code segment and the C code variable. The format is as follows:
"M" "V" "O" ---- memory unit
"R" ---- any register
"Q" ---- register eax, EBX, ECx,
"I" "H" ---- direct operand
"E" "F" ---- floating point number
"G" ---- arbitrary
""" B "" C "" D "-eax is used, EBX, ECx, EDX
"S" "D" ---- use ESI, EDI
"I" ---- constant (0-31)

Related Article

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.