General
Declarations
Procedures
Assembler
8051

 

 

Assembler Compiler internals Reentrant procedures

Reentrant procedures

For reentrant procedures all parameters are pushed on XDATA stack. Functions return simple result in first register set (R5R4R3R2). For functions which return String result calle must reserve space on XDATA stack and push its address (see picture below). Before a call to the reentrant procedure is made the following is pushed on the XDATA stack:
  1. Address for String result (for functions which return String)
  2. All parameters in order in which they were declared
  3. XBP if calling local procedure

Called procedure on entry:

  1. pushes XBP
  2. sets XBP to point to the top of pushed parameters
  3. reserves space for local variables (increases XSP accordingly)

 

On exit called procedure pops saved XBP and removes all pushed parameters from XDATA stack. XDATA stack during reentrant procedure call looks like this:

 





XDATA STACK

low memory




Pushed address for String result

(for functions which return String)




Pushed parameters




Outer procedure's XBP

(if there is outer procedure)

<- XBP - 4


Saved XBP

 

<- XBP - 2


Result variable

(for functions which return simple type)

<- XBP




Local variables and

temporary storage






XDATA STACK

high memory



<- XSP