Discussion Forum

Reentrant function whose arguments are located to absolute addr

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
Bryan Wang
Posted
19-Jul-2004 14:10 GMT
Toolset
C51
New! Reentrant function whose arguments are located to absolute addr
I defined a reentrant function with 4 long arguments like this (excerpt from the lst)
  21          unsigned long func0(unsigned long a, unsigned long b, unsigned long c, unsigned long d) large reentrant
  22          {
  23   1              printf("--- Now in func 0 Calling bank A\n");
  24   1              func5A(a,b,c,d);
  25   1              printf("--- Calling bank B\n");
  26   1              func8B(d,c,b,a);
  27   1              return a+b+c+d;
  28   1      }
Read-Only
Author
Bryan Wang
Posted
19-Jul-2004 14:14 GMT
Toolset
C51
New! RE: Reentrant function whose arguments are located to absolute addr
And part of its translated form in assembly is
             ; FUNCTION _?func0 (BEGIN)
                                           ; SOURCE LINE # 21
0000 90FFFC            MOV     DPTR,#0FFFCH
0003 120000      E     LCALL   ?C?ADDXBP
0006 120000      E     LCALL   ?C?LSTXDATA
                                           ; SOURCE LINE # 23
0009 7BFF              MOV     R3,#0FFH
000B 7A00        R     MOV     R2,#HIGH ?SC_120
000D 7900        R     MOV     R1,#LOW ?SC_120
000F 120000      E     LCALL   _printf
The first MOV is to get the argument values (?) from $FFFC, however it happens to be an "empty" address in my chip. How does it happen? I supposed the argument address are determined only when linking, rather than compiling.
Read-Only
Author
Jon Ward
Posted
19-Jul-2004 14:25 GMT
Toolset
C51
New! RE: Reentrant function whose arguments are located to absolute addr
Did you setup the reentrant stack pointer in the startup code?

http://www.keil.com/support/docs/671.htm

Jon
Read-Only
Author
Bryan Wang
Posted
19-Jul-2004 16:13 GMT
Toolset
C51
New! RE: Reentrant function whose arguments are located to absolute addr
Thanks for answering. It works fine now.
Read-Only
Author
Bryan Wang
Posted
20-Jul-2004 16:13 GMT
Toolset
C51
New! RE: Reentrant function whose arguments are located to absolute addr
I found the answer in
http://www.keil.com/support/docs/1431.htm.
Thanks anyway :)
Read-Only
Author
Bryan Wang
Posted
20-Jul-2004 15:12 GMT
Toolset
C51
New! RE: Reentrant function whose arguments are located to absolute addr
Another problem arose. What is the stack pointer of the reentrant functions and how to set it in the program, in C or ASM?
Read-Only
Author
Bryan Wang
Posted
20-Jul-2004 16:00 GMT
Toolset
C51
New! RE: Reentrant function whose arguments are located to absolute addr
I found the ?C_XBP is the reentrant stack pointer. Is there any way to locate it to a fixed address? I mean, I want to fix it at, say, D:0x08, and nowhere else.
Thanks!
Read-Only
Author
Bryan Wang
Posted
20-Jul-2004 16:14 GMT
Toolset
C51
New! RE: Reentrant function whose arguments are located to absolute addr
I found the answer in
http://www.keil.com/support/docs/1431.htm.
Thanks anyway :)

Next Thread | Thread List | Previous Thread Start a Thread | Settings