

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Homework # Due: October 17, 2007 Problem #1. Provide short answers for the following questions: 1.a Which register is used for the Stack Pointer? Does the Stack Pointer point to the next available location on the stack or the last used entry? 1.b Which register is used for the Link Pointer? What is kept in the link register? 1.c List the registers used for passing parameters into subroutines 1.d List the registers used for returning parameters from subroutines 1.e List the volatile registers and state who is responsible for saving them 1.f List the non-volatile registers and state who is responsible for saving them. 1.g. List the fields and show their ordering for the ABI defined stack Frame. Show which fields are optional. 1.e What instruction is used to save the program counter and branch to a subroutine? 1.f What instruction is used to restore the program counter and return to the calling routine?
Problem #2. For this problem, you are to show the assembler code for performing the necessary stacking, branching, and returning from subroutine. Assume that the stack pointer is initially pointing to location 0000FF00, the link register contains 0, and the values of int a and int b are in registers R19, and R20. You may use registers to pass and return values between the main and my_routine, and you must use the stack to pass values between my_routine and your_routine. #include <stdio.h> main(){ int a,b,c; c = my_routine(a, b); /** brlid instr @ 00000100 / printf("value of C is %d\n",c); } /* subroutine my_routine / int my_routine(int e, int f){ / my_routine @00000200 / int c; c = your_routine(e); / brlid instr @00000220 / return(c+f); / rtsd instr @000002A0 / } / end subroutine my_routine / / begin subroutine your_routine / int your_routine(int yes){ / your_routine @00000300 / int h = yes; return h;} / rtsd instr @000003f0 / / end subroutine your_routine ***/ Adhere to the ABI standard conventions when answering the following questions. a. List the assembler instructions for the main routine. b. Show the contents of the Stack Pointer, Link Register and Stack immediately before and after the brlid instr @00000100 is executed. c. List the assembler instructions for my_routine. d. Show the contents of the Stack Pointer, Link Register and Stack immediately before and after the brlid instr @00000220 is executed. e. List the assembler instructions for your_routine f. Show the contents of the Stack Pointer, Link Register and Stack immediately before and after the rtsd isntr @ooooo3f0 is executed. g. Show the contents of the Stack Pointer, Link Register and Stack immediately before and after the rtsd isntr @000002A0 is executed.