Unresolved: the issue of using C51 to interact with assembly programming in C51 subfunctions

Source: Internet
Author: User

The source file CIDR block of C51 is as follows:

Void main ()
{
Jn1 = 1;
Jn2 = 0;
While (1)
{
Jn1 = 0;
Delay (1 );

Jn1 = 1;
Delay (1 );



// Pulse ();
}

}

Void delay (u8 counter)
{
For (; counter> 0; counter --)
{

//

// Note the followingProgramThe Assembly SRC file generated after interactive compilation.
//

# Pragma ASM
NOP
NOP
NOP
NOP
# Pragma endasm
 
}
}

 

The optional segments of the Assembly SRC file generated after the interactive compilation are as follows:

Rseg? PR? Main? Main
Main:
Using 0
; Source line #18
;{
; Source line #19
; Jn1 = 1;
; Source line #20
SETB jn1
; Jn2 = 0;
; Source line #21
CLR jn2
? C0001:
; While (1)
; Source line #22
;{
; Source line #23
; Jn1 = 0;
; Source line #24
CLR jn1
; Delay (1 );
; Source line #25
MoV R7, #01 H
Lcall _ Delay
;
; Jn1 = 1;
; Source line #27
SETB jn1
; Delay (1 );
; Source line #28
MoV R7, #01 H
Lcall _ Delay
;
;
;
; // Pulse ();
;}
; Source line #33
Sjmp? C0001
; End of main

;
;}
;
; Void delay (u8 counter)

Rseg? PR? _ Delay? Main
_ Delay:
Using 0
; Source line #37
; ---- Variable 'counter? 140 'assigned to register 'r7 '----
;{
; Source line #38
; For (; counter> 0; counter --)
; Source line #39
? C0004:
MoV A, r7
SETB C
Subb A, #00 h
JC? C0007
;{
; Source line #40
; Counter ++;
; Source line #41
INC r7
; # Pragma ASM
; NOP
NOP
; NOP
NOP
; NOP
NOP
; NOP
NOP
; # Pragma endasm
;
;}
; Source line #49
Dec r7
Sjmp? C0004
;}
; Source line #50
? C0007:

;

Note: After the C51 calls the subfunction, the main function is directly returned instead of executing the NOP statement.

;
RET
; End of _ Delay

Postscript:

I have no clue about this question. If you have any answers, please contact me. Thank you for your advice!

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.