Analysis of Embedded Assembly Applets in arm-linux
Source: Internet
Author: User
Analysis of arm-linux Embedded Assembly applet-general Linux technology-Linux programming and kernel information. The following is a detailed description. # Define _ range_ OK (addr, size )({\
Unsigned long flag, sum ;\
_ Asm _ ("adds % 1, % 2, % 3; sbcccs % 1, % 1, % 0; movcc % 0, #0 "\
: "= & R" (flag), "= & r" (sum )\
: "R" (addr), "Ir" (size), "0" (current-> addr_limit )\
: "Cc ");\
Flag ;})
Understanding of Embedded Assembly:
// Remember gliethttp 7.7
1. "= & r" (flag)
1.1 & indicates that the output data will not be overwritten
1.2 = & r (flag) % 0 flag is the output unit. r indicates that the Register r is used as the reference of the flag variable, rather than memory, which is volatile.
2. "= &" (sum) % 1 sum is the output unit, and the r register is used as the reference of sum.
3. "r" (addr) % 2 the input unit variable addr is referenced in the r register
4. "Ir" (size) % 3 the size of the 32-bit input unit is referenced in the r register.
5. "0" (current-> addr_limit) % 4 enter the unit variable current-> addr_limit to reference with the r register of % 0,
That is, before entering the _ asm _ Embedded Assembly command, the input variable % 4 is assigned a value, that is, the r register of % 0 is assigned a value of current-> addr_limit.
6. "cc" the embedded _ asm _ Assembly command will change the CPU condition Status Register cc
7. flag; tell the gcc compiler that the flag serves as the final return value of the output variable unit, that is, sum is only the intermediate amount of the output unit,
If there is only one output unit, the flag is unnecessary;
However, there is also a flag = 0; this means that the comparison result of flag = 0; is used as the final output return value.
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