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 }
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
Did you setup the reentrant stack pointer in the startup code? http://www.keil.com/support/docs/671.htm Jon
Thanks for answering. It works fine now.
Another problem arose. What is the stack pointer of the reentrant functions and how to set it in the program, in C or ASM?
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!
I found the answer in http://www.keil.com/support/docs/1431.htm. Thanks anyway :)