spo600:procedure_call
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
spo600:procedure_call [2025/02/19 17:17] – created chris | spo600: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 " | - A program (known as the //caller//) uses an [[instruction]] to invoke the procedure. This is known as " | ||
- The current value of the [[register# | - The current value of the [[register# | ||
- | - 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# | + | - The return operation is performed by loading the return address into the [[register# |
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 actual value of the return address saved during a procedure call may be the address of the first byte of the call instruction, | ||
Line 15: | Line 15: | ||
Note that the return address is saved differently by various architectures: | Note that the return address is saved differently by various architectures: | ||
* Some systems store the return address into a //link register//. This has the advantage of avoiding access to the main memory, which is much slower than registers. However, if a called procedure needs to call another procedure, it must save the contents of the link register. | * Some systems store the return address into a //link register//. This has the advantage of avoiding access to the main memory, which is much slower than registers. However, if a called procedure needs to call another procedure, it must save the contents of the link register. | ||
- | * 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, |
spo600/procedure_call.1739985434.txt.gz · Last modified: 2025/02/19 17:17 by chris