User Tools

Site Tools


spo600:procedure_call

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
spo600:procedure_call [2025/02/19 17:19] chrisspo600:procedure_call [2025/02/19 17:42] (current) chris
Line 6: Line 6:
   - A program (known as the //caller//) uses an [[instruction]] to invoke the procedure. This is known as "performing a call".   - A program (known as the //caller//) uses an [[instruction]] to invoke the procedure. This is known as "performing a call".
     - The current value of the [[register#program_counter|program counter]] is saved either to a [[stack]] or to a [[register]]. This is known as the //return address//.     - The current value of the [[register#program_counter|program counter]] is saved either to a [[stack]] or to a [[register]]. This is known as the //return address//.
-    - The address of the entry point in the called procedure is loaded into the system'.+    - The address of the entry point in the called procedure is loaded into the program counter. This causes the first instruction of the procedure to be executed next.
   - The called procedure (known as the //callee//) executes zero or more instructions.   - The called procedure (known as the //callee//) executes zero or more instructions.
   - The callee executes an instruction to //return// to the caller.   - The callee executes an instruction to //return// to the caller.
-    - The return operation is performed by loading the return address into the [[register#program_counter|program counter]].+    - The return operation is performed by loading the return address into the [[register#program_counter|program counter]]. This causes the instruction after the call to be executed next.
  
 The actual value of the return address saved during a procedure call may be the address of the first byte of the call instruction, the last byte of the call instruction, or the first byte of the instruction following the call instruction, depending on the architecture of the system. The actual value of the return address saved during a procedure call may be the address of the first byte of the call instruction, the last byte of the call instruction, or the first byte of the instruction following the call instruction, depending on the architecture of the system.
Line 17: Line 17:
   * Other systems store the return address on the [[stack]]. This is slower but does not require additional code when performing a subsequent call.   * Other systems store the return address on the [[stack]]. This is slower but does not require additional code when performing a subsequent call.
  
 +The location of parameters passed to a procedure, the location of the return value(s), and which registers must be preserved by the called procedure and which ones may be clobbered, is not usually defined as part of the hardware architecture, but as part of an //Application Binary Interface// (ABI) document, sometimes called a //Procedure Call Standard//.
spo600/procedure_call.1739985575.txt.gz · Last modified: 2025/02/19 17:19 by chris

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki