Question: Consider the following program written in Ada syntax with the execution stack shown on the side. The line numbers are used to refer to the
Consider the following program written in Ada syntax with the execution stack shown on the side. The line numbers are used to refer to the code and are not part of the code.
| 01 | procedure env is |
| ||||||||
| 02 | x_env: integer; | |||||||||
| 03 |
| |||||||||
| 04 | procedure a is |
|
|
| env | |_______| | 1 | |||
| 05 | x_a: integer; |
|
|
| a | |_______| | 2 | |||
| 06 | procedure b | is |
|
| d | |_______| | 3 | |||
| 07 | x_b: integer; |
|
| b | |_______| | 4 | ||||
| 08 | procedure c | is |
| c | |_______| | 5 | ||||
| 09 |
| x_c: integer; |
| a | |_______| | 6 | ||||
| 10 |
| begin |
| d | |_______| | 7 | ||||
| 11 |
| x_env = x_b + | x_a; | b | |_______| | 8 | ||||
| 12 |
| a; |
| c | |_______| | 9 | ||||
| 13 |
| end c; |
| a | |_______| | 10 | ||||
| 14 | begin |
|
| d | |_______| | 11 | ||||
| 15 |
|
| x_b = x_a; |
|
| b | |_______| | 12 | ||
| 16 |
|
| c; |
|
|
|
|
| ||
| 17 |
|
| end b; |
|
|
|
|
| ||
| 18 |
|
|
|
|
|
|
|
| ||
| 19 |
|
| procedure d is |
|
|
|
|
| ||
| 20 |
|
| begin |
|
|
|
|
| ||
| 21 |
|
| b; |
|
|
|
|
| ||
| 22 |
|
| end d; |
|
|
|
|
| ||
| 23 |
| begin |
|
|
|
|
|
| ||
| 24 |
| d; |
|
|
|
|
|
|
| 25 |
| end a; |
|
|
|
|
|
|
| 26 | begin |
|
|
|
|
|
|
|
| 27 | a; |
|
|
|
|
|
|
|
28 end env;
Explain how the access links of activation records 6, 7, and 8 are found.
Explain how the address of x_a in line 11 is calculated. Also, give the formula for the address.
Explain how the address of x_a in line 15 is calculated. Also, give the formula for the address.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
