The first C program embedded in the Assembly

Source: Internet
Author: User

I learned about the Linux kernel in the last two days. I have benefited a lot from reading Dr. Zhao's "Linux kernel complete notes. Today, I saw Chapter 3 embedded in the assembly part, so I wrote a small program to test it and compiled it with gcc. The Code is as follows:

# Include <stdio. h> <stdlib. h> <. h> ** StrCopy (array * a1, array * register *, a1->, a2-> (a1-> size> a2-> chlist = (*) malloc (a1-> size * (-> size = a1-> :( a2-> chlist), (a1-> chlist ), (a1-> main (* = l2.chlist = l2.size = strlen (l1.chlist) + str = StrCopy (& l1 ,&

This function allows you to copy strings.

At the beginning, the last line of the assembly part is written as follows:

:,,,

Compilation error:

StrCopy. c ::: error: can't find a register 'creg': Error: 'asm 'contains impossible constraints in the operand

After checking the cause on the internet, I learned from a blog post that "edi", "esi", "ecx" has been provided in the input list and will be given again in the modified register list, gcc reports an error. Modified and compiled.

 

 

 

 

 

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.