Question: Question: First 2 pics. Figures given examples: Figure 8/5 next 2 pics. Last pic is what i have so far, confused on stack values, and

Question: First 2 pics.
Figures given examples: Figure 8/5 next 2 pics.
Last pic is what i have so far, confused on stack values, and Relative/Absolute addresses. I know the BP (Base Pointer to previous frame address) increments positive upwards and negative downwards. And the absolute address should be the previous address minus the byte size of the current line. But whats the syntax? i.e. what does the FA9h mean, F87h, etc. and where do i begin with the stack values or how to write them. please post a solution (pic) so that i can see what you did to learn how to do this, thank you.
 Question: First 2 pics. Figures given examples: Figure 8/5 next 2
pics. Last pic is what i have so far, confused on stack
values, and Relative/Absolute addresses. I know the BP (Base Pointer to previous
frame address) increments positive upwards and negative downwards. And the absolute address
should be the previous address minus the byte size of the current

C2A2E3 (6 points - Drawing only - No program required) Please refer to figure 8 of note 12.4D and figure 5 of note12.6C in the course book. Both illustrate the final state of the call stack before any returns have occurred in their respective programs. Create a similar single figure based upon the assumptions and program code provided below. If you create multiple figures you are doing this exercise incorrectly. Your figure must: Begin with the "startup" stack frame shown in figure A on the next page and append additional stack frames using the general format and item ordering illustrated in the next frame in that figure. Show only stack frame items for the functions below. Use a double question mark for all return object values, values dependent upon return objects, and values for which you believe insufficient information has been provided. Represent all addresses and BP offsets in hexadecimal and all other numeric values in decimal. Suffix all hexadecimal values with an h but do not suffix decimal values. Create your figure using a computer application of your choice, such as a text editor, Word, Visio, Excel. etc. Then convert it to a PDF file named C2A2E3_StackFrames.pdf for submission. NO CREDIT will be given if your file: ...contains anything hand-drawn or difficult to read, or ....cannot be printed on one standard 8-1/2" by 11" page without size reduction, or . ...contains a stack frame item that will not fit entirely on one line. The code below Uses different types and sizes for exercise diversity. Assume the following: Any necessary header files and prototypes are present. . "Pascal calling convention" short: 3 bytes, int: 4 bytes. long: 8 bytes, addresses(pointers): 6 bytes int main() The "startup function" calls main { and main returns to it. Function main int result = gcd(176.77): Operation Instruction Address return 0; ) assignment to result 580h long gcd(int x, shorty) { it ly == 0) return return gcdly.x%y); } Function ged Operation Instruction Address the return on line 36 1E0h Waypoints: Check the following to help you determine if you might have a problem: The gcd function will have 4 stack frames. each containing 5 items. The absolute address of the last item in the last stack frame will be B39h. . There should be exactly 7 stack values that are double questions marks. Continued on the next page... Submitting your solution Send your PDF file to the assignment checker with the subject line C2A2E3_ID, where ID is your 9-character UCSD student ID. See the course document titled "How to Prepare and Submit Assignments" for additional exercise formatting, submission, and assignment checker requirements. Figure A Required "startup" Stack Frame and General Stack Frame Format The figure below was created as a table in Microsoft Word, but you may use any computer application you wish as long as you present the required information in the same basic format. Place a divider prior to each stack frame that indicates the name of the function. If the function is being used recursively. indicate the recursion level after the name starting with 1. Relative Address Absolute Address BP+6h BP BBFh BB9h Stack Value Description startup 1014h Function Return Address Oh Previous Frame Address FunctionName 13 ?? Return Object BP+... BP+... BP+... BP+... BP+... .. names of specifically ordered formal parameters As many of these stack frames as needed. Function Return Address Previous Frame Address BP BP-... BP-... names of arbitrarily ordered Local automatic variables: BP- Notes: 1. Space for the return object, formal parameters, and Local automatic variables is not allocated if the function does not have them. 2. The order of formal parameters depends upon which calling convention is used. 3. Only indicate a Level if the function is being used recursively. Figure 8 Memory Addresses 'Relative Absolute BP+?? ?? BP+?? FC2h Stack Values ?? 22 Stack View fcnB complete startup Stack Frame: Description ?? ?? Return Object (int) Function Return Address Previous Frame Address ?? BP+8h BP+4h FC0h FBCh 7? main Stack Frame ?? 2.8 BP FB8h BP+10h FBOh BP+8h FA8h With Relative Addresses Shown horse 7.5 BP+4h FA4h FAO 3AC2h FB8h pig Function Return Address Previous Frame Address fcna Stack Frame BP F9Eh ?? XA BP-2h BP-4h F9Ch 81 YA BP+Ah F9Ah 29 F98h -7 BP+8h BP+4h F94h 21F8h FAOh dog cat Function Return Address Previous Frame Address WB fcnB Stack Frame BP F90h BP F90h BP-8h F88h 5.6 SP F80h BP-10h F80h ?? zB Figure 5 Stack View Stack Values ?? ?? ?? startup Stack Frame Final State Description ?? 7? Return Object (int) Function Retur Address Previous Frame Address Memory Addresses Relative Absolute BP+?? ?? BP+?? FA9h BP+6h FA7h BP+3h FA4h BP FA1h BP-2 F9Fh BP+3 F9Ch BP F99h ?? 22 main Stack Frame ?? 200h F97h BP+6h BP+3h FA1h 397 116h F99h Ready Stack Frame 1 Frame Recur Stack F94h F91h BP BP+6h F8Fh 39 Function Retum Address Previous Frame Address value Function Return Address Previous Frame Address value Function Return Address Previous Frame Address value Function Return Address Previous Frame Address 7BE F8Ch F89h F91 h BP+3h BP BP+6h BP+3h BP Recur Stack Frame 3 Frame 2 Recur Stack F87h F84h BP F81h SP F81h 3 7BE F89h F81h Relative Address BP+6h BP Absolute Address Stack Value 1014h BB9h Oh -main Description Function Return Address Previous Frarne Address ?? ?? Return Object (int) Function Return Address Previous Frame Address result BP Return Function Return Address Previous Frame Address y 77 176 gcd2 ?? BP Result Function Return Address Previous Frame Address y X 22 77 -gcd3 72 BP Result Function Return Address Previous Frame Address EY 11 22 ?? BP Result Function Return Address Previous Frame Address v mein 2- 11 C2A2E3 (6 points - Drawing only - No program required) Please refer to figure 8 of note 12.4D and figure 5 of note12.6C in the course book. Both illustrate the final state of the call stack before any returns have occurred in their respective programs. Create a similar single figure based upon the assumptions and program code provided below. If you create multiple figures you are doing this exercise incorrectly. Your figure must: Begin with the "startup" stack frame shown in figure A on the next page and append additional stack frames using the general format and item ordering illustrated in the next frame in that figure. Show only stack frame items for the functions below. Use a double question mark for all return object values, values dependent upon return objects, and values for which you believe insufficient information has been provided. Represent all addresses and BP offsets in hexadecimal and all other numeric values in decimal. Suffix all hexadecimal values with an h but do not suffix decimal values. Create your figure using a computer application of your choice, such as a text editor, Word, Visio, Excel. etc. Then convert it to a PDF file named C2A2E3_StackFrames.pdf for submission. NO CREDIT will be given if your file: ...contains anything hand-drawn or difficult to read, or ....cannot be printed on one standard 8-1/2" by 11" page without size reduction, or . ...contains a stack frame item that will not fit entirely on one line. The code below Uses different types and sizes for exercise diversity. Assume the following: Any necessary header files and prototypes are present. . "Pascal calling convention" short: 3 bytes, int: 4 bytes. long: 8 bytes, addresses(pointers): 6 bytes int main() The "startup function" calls main { and main returns to it. Function main int result = gcd(176.77): Operation Instruction Address return 0; ) assignment to result 580h long gcd(int x, shorty) { it ly == 0) return return gcdly.x%y); } Function ged Operation Instruction Address the return on line 36 1E0h Waypoints: Check the following to help you determine if you might have a problem: The gcd function will have 4 stack frames. each containing 5 items. The absolute address of the last item in the last stack frame will be B39h. . There should be exactly 7 stack values that are double questions marks. Continued on the next page... Submitting your solution Send your PDF file to the assignment checker with the subject line C2A2E3_ID, where ID is your 9-character UCSD student ID. See the course document titled "How to Prepare and Submit Assignments" for additional exercise formatting, submission, and assignment checker requirements. Figure A Required "startup" Stack Frame and General Stack Frame Format The figure below was created as a table in Microsoft Word, but you may use any computer application you wish as long as you present the required information in the same basic format. Place a divider prior to each stack frame that indicates the name of the function. If the function is being used recursively. indicate the recursion level after the name starting with 1. Relative Address Absolute Address BP+6h BP BBFh BB9h Stack Value Description startup 1014h Function Return Address Oh Previous Frame Address FunctionName 13 ?? Return Object BP+... BP+... BP+... BP+... BP+... .. names of specifically ordered formal parameters As many of these stack frames as needed. Function Return Address Previous Frame Address BP BP-... BP-... names of arbitrarily ordered Local automatic variables: BP- Notes: 1. Space for the return object, formal parameters, and Local automatic variables is not allocated if the function does not have them. 2. The order of formal parameters depends upon which calling convention is used. 3. Only indicate a Level if the function is being used recursively. Figure 8 Memory Addresses 'Relative Absolute BP+?? ?? BP+?? FC2h Stack Values ?? 22 Stack View fcnB complete startup Stack Frame: Description ?? ?? Return Object (int) Function Return Address Previous Frame Address ?? BP+8h BP+4h FC0h FBCh 7? main Stack Frame ?? 2.8 BP FB8h BP+10h FBOh BP+8h FA8h With Relative Addresses Shown horse 7.5 BP+4h FA4h FAO 3AC2h FB8h pig Function Return Address Previous Frame Address fcna Stack Frame BP F9Eh ?? XA BP-2h BP-4h F9Ch 81 YA BP+Ah F9Ah 29 F98h -7 BP+8h BP+4h F94h 21F8h FAOh dog cat Function Return Address Previous Frame Address WB fcnB Stack Frame BP F90h BP F90h BP-8h F88h 5.6 SP F80h BP-10h F80h ?? zB Figure 5 Stack View Stack Values ?? ?? ?? startup Stack Frame Final State Description ?? 7? Return Object (int) Function Retur Address Previous Frame Address Memory Addresses Relative Absolute BP+?? ?? BP+?? FA9h BP+6h FA7h BP+3h FA4h BP FA1h BP-2 F9Fh BP+3 F9Ch BP F99h ?? 22 main Stack Frame ?? 200h F97h BP+6h BP+3h FA1h 397 116h F99h Ready Stack Frame 1 Frame Recur Stack F94h F91h BP BP+6h F8Fh 39 Function Retum Address Previous Frame Address value Function Return Address Previous Frame Address value Function Return Address Previous Frame Address value Function Return Address Previous Frame Address 7BE F8Ch F89h F91 h BP+3h BP BP+6h BP+3h BP Recur Stack Frame 3 Frame 2 Recur Stack F87h F84h BP F81h SP F81h 3 7BE F89h F81h Relative Address BP+6h BP Absolute Address Stack Value 1014h BB9h Oh -main Description Function Return Address Previous Frarne Address ?? ?? Return Object (int) Function Return Address Previous Frame Address result BP Return Function Return Address Previous Frame Address y 77 176 gcd2 ?? BP Result Function Return Address Previous Frame Address y X 22 77 -gcd3 72 BP Result Function Return Address Previous Frame Address EY 11 22 ?? BP Result Function Return Address Previous Frame Address v mein 2- 11

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!