What are the rules for passing return values ​​from C51 functions?

Publisher:SerendipityJoyLatest update time:2013-03-12 Source: 21ic Keywords:C51 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

In C51, what are the rules for function return value passing?

Answer : (1) Parameter passing during calling

There are three cases: when there are less than or equal to 3 parameters, they are passed through registers (if there are not enough registers, they are passed through the storage area); when there are more than 3 parameters, some of them are passed through the storage area, and for reentrant function parameters, they are passed through the stack. Passing through registers is the fastest.

(2) Transfer of function return value

When a function returns a value, it is passed through registers.

Keywords:C51 Reference address:What are the rules for passing return values ​​from C51 functions?

Previous article:MCU music program
Next article:Single chip stopwatch course design

Recommended ReadingLatest update time:2024-11-16 15:30

Microcontroller C51 programming specifications
1 Single-Chip Microcomputer C51 Programming Specifications - Preface This specification is written to improve the quality and maintainability of source programs, and ultimately improve the productivity of software products. 2 MCU C51 Programming Specifications - Scope This standard specifies the spe
[Microcontroller]
A multi-tasking mechanism and application based on C51
Introduction   Traditional microcontroller programs generally use a single-task mechanism. Single-task systems have the advantages of being simple, intuitive, and easy to control. However, since the program can only be executed in sequence and lacks flexibility, interrupt functions can only be used to process some sh
[Microcontroller]
"Beginner's C51 Self-study Notes" implementation of running water lamp (shift operation)
#include reg52.h #define uchar unsigned char  #define uint unsigned int   void delay(void) { uchar a,b; for(a=0;a 200;a++) for(b=0;b 200;b++); }   void main() { uchar k,i; while(1) { k=0xfe; //11111110 for(i=0;i 8;i++) { P0=k; delay(); k=k 1; //11111100 k=k|0x01; //The end becomes 1 1111110
[Microcontroller]
Data types of single chip microcomputer C language C51
The data types of C51 are divided into basic data types and combined data types, which are basically the same as the data types in standard C, but the char type is the same as the short type, and the float type is the same as the double type. In addition, C51 also has special function register types and bit types spec
[Microcontroller]
Data types of single chip microcomputer C language C51
The difference between the no-operation NOP instruction in ARM and C51
(I) C51 calling method #include intrins.h  _nop_(); (II) Calling method under ARM  __asm void nop(void) {     NOP } Then call this function in the following C code: void main() { ... nop(); ...  }   About NOP instruction In the MCS-51 microcontroller instruction set, the instruction code o
[Microcontroller]
Keil C51's 13th keyword extension of C language: sfr
sfr is used to define special function registers. The usage is as follows: sfr name = address; name is the register name address is the address of the register Example: sfr P0 = 0x80; /* P0 port, address is 0x80 */ sfr P1 = 0x90; /* P1 port, address is 0x90 */ sfr P2 = 0xA0; /* Port 2, address 0xa0 */ sfr P3 = 0xB
[Microcontroller]
General Rules for C51 MCU Programming
Introduction: This standard specifies the specifications that programmers must follow when designing programs. This standard is mainly for the C51 programming language and the Keil compiler, including typesetting, comments, naming, variable usage, code testability, program efficiency, quality assurance, etc. 1. Sing
[Microcontroller]
A problem about data and xdata encountered in C51 has been solved
environment: I defined a structure variable in a C file, and then the variable was only used by a function in this file. Then I called the function in an interrupt to change the output state of an IO port. As a result, I could not achieve the desired effect when executing it. struct BE   {       unsigned int Coun
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号