Keil Logo


Information in this article applies to:

  • C51 All Versions


I understand that when a function is called, parameters are passed to registers. In my listing file, I have noticed that some of the parameters are stored in segments with names that look like ?_function?BYTE. What does this actually mean?


The following is an example program with the resulting listing file:

unsigned int bar (unsigned long arg1,unsigned long arg2, unsigned long arg3)
   unsigned long abc;

   abc = arg1 + arg2 + arg3;

   return (abc);

void main (void)
   // This call generates the following assembly listing


               ; FUNCTION main (BEGIN)

0000 E4                CLR     A
0001 7500D7      R     MOV     ?_bar?BYTE+07H,#0D7H
0004 750011      R     MOV     ?_bar?BYTE+06H,#011H
0007 F500        R     MOV     ?_bar?BYTE+05H,A
0009 F500        R     MOV     ?_bar?BYTE+04H,A

000B 7500D2      R     MOV     ?_bar?BYTE+0BH,#0D2H
000E 75001E      R     MOV     ?_bar?BYTE+0AH,#01EH
0011 F500        R     MOV     ?_bar?BYTE+09H,A
0013 F500        R     MOV     ?_bar?BYTE+08H,A

0015 7FD2              MOV     R7,#0D2H
0017 7E04              MOV     R6,#04H
0019 FD                MOV     R5,A
001A FC                MOV     R4,A
001B 020000      R     LJMP    _bar

               ; FUNCTION main (END)

The function bar() was called with 3 long (or 4-byte) parameters giving a total of 12 bytes. This is why there are 12 MOV instructions in the listing. The C51 can only pass 3 parameters in registers and depending on the size of these parameter types, there may not be enough registers for all 3 parameters. Therefore, the C51 compiler assigns a fixed memory location for the rest of the parameters.

Since the function parameters in this example require a total of 12 bytes, the first 4 bytes (arg1) are stored in registers R4-R7, the next 4 bytes (arg2) are stored in the function's data segment ?_bar?Byte starting from byte# 8 - 11, and the last 4 bytyes (arg3) occupy byte #s 4 - 7. Which argument goes to a specific byte range is determined by the compiler.




The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Thursday, September 22, 2005

Did this article provide the answer you needed?
Not Sure
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.