How to implement hybrid programming for C51 and assembly

Source: Internet
Author: User

The compiler used in this article is Keil
The first is an example, and from this example unfolds the description:
......//c51 Code Here
#pragma ASM
.....//here is the the assembler Code.
#pragma endasm
......//c51 Code Here

Oh, in fact, C51 and assembly of mixed programming is just such a thing.
But we also have to do some premise work, first in the Project window containing assembly code (ASM) C file Right-click, select "Options for ...", and then click "Generate assembler src File" and "Assemble SRC File "

According to the selected compilation mode, the corresponding library files are added to the project, it should be noted that this file must be the last file of the project


        is a complete routine
#i nclude <reg51.h>
void main (void)
{
     p2=1;
     #pragma asm
          MOV R7, #10
& nbsp;    Del:mov R6, #20
          DJNZ r6,$
          DJNZ r7,del
     #pragma endasm
     p2=0;
}

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.