Passing parameters and the return value using registers

When a compiler processes a function definition:

  int f( int[] A, int a, int b )           
  {
     ....
  }
   

When registers are used for parameter passing, the compiler will:

  • Remember the name and data type of each parameter:

  • Designate (= assign/reserve) a register for the parameter

    Example:

     Function f:
    
             Parameter Name     Data Type     Location
           ------------------------------------------------
       0           A              int[ ]        r0
       1           a              int           r1
       2           b              int           r2
    

Note:   the return value is usually returned in register r0 by compilers - we will adopt this.