Write from assembly language to C language

Source: Internet
Author: User

OK, so, the bare-metal program does not have the support of the operating system, want to use C language, you can only use assembly language to manually configure the C language needs of the environment, sounds very tall, in fact, need to do is very simple: specifying the value of the stack pointer is good .

So before you complete this simple thing, understand the following concepts of the C-language stack:

1. empty stack and full stack: These two concepts are not that the stack is empty or full, the empty stack refers to the stack pointer to the top of the stack of the next address of the element. Full stack refers to the stack top pointer refers to the top element of the stack.

2. stack up and down: the stack is up and down the stack.

Note: ARM is a full-fall stack.

3. stack frame: This is necessary to understand,in C, each stack frame corresponds to a function that is not finished running. You can understand the imaging Ucos: each process has a separate stack space, which is the stack frame. But the stack frame in C is a connected one, such as a function call B function, then the B function execution, the stack frame of a function is the stack frame of the B function, the B function finishes, the SP moves up, completes the stack.

such as (main function call func1): all stack frames are concatenated, which is the complete stack . The most recent stack frame boundary is determined by the FP pointer, and the lower boundary is specified by the SP pointer, where LR and SP point to the upper and lower bounds of the stack frame of the caller of the function corresponding to the stack frame, respectively.



From for notes (Wiz)

Write from assembly language to C language

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.