3. (40 points, 10 pts each) Given the below program of the RISC machine with a 3
ID: 2267510 • Letter: 3
Question
3. (40 points, 10 pts each) Given the below program of the RISC machine with a 32-bit word size, what are the stack contents and the contents of the stack pointer (SP), in hexadecimal, immediately after each of the following instruction of the program is executed? Assume that [SP] 0xFF00 at Leve, before the execution of the calling program begins. Assume the contents of R5, R6, and R7 are initially 0x1A, 0x2D, and 0x3F, respectively. The content of memory word SIZE is 0x8. is the starting memory address of two consecutive 32-bit data words: 0x5362 ECEF and 0x66150914. Two = 0xB000 is the starting memory address of two consecutive 32-bit data words: 0x5342ECEF and 0x66160918. Note for the stack contents, also show those contents (if any) that have been previously popped out of the stack. Instruction LoadByte R6, LOC is used to load a memory byte at LOC to the least significant (rightmost) byte of register R6. LoadByte loads a byte from the memory into the rightmost eight bit positions of a 32-bit processor register and clears the remaining higher- order bits to zero. Assume we do not use stack for storing return address (i.e., PC) a) The first Store instruction in the calling program. b) The second Store instruction in the subroutine. c) The last Store instruction in the subroutine d) The last Add instruction in the subroutine. Load Move Move R2, SIZE R3. #ONE R4. #TWO SP, SP, #4 SubtractRo, (SP) Store Call next instruction SUBROUT SUBROUT: Subtract SP. SP, #12 R5, 8(SP) R6, 4(SP) R7, (SP) R5, 12(SP) R8, (R3) Store Store Store Load LoadByte R6. (R3) LoadByte Branch if R6R7 SKIP Add LoadByte R8, (R3) Add Add Subtract Branch if [R21P[RO LOOP Store Store Load Load Load Add Return LOOP: R7. (R4) RS, R5#1 SKIP R3, R3, #1 R4, R4#1 R2, R2, #1 R8, 16(SP) R5, 12(SP) R7, (SP) R6, 4(SP) R5, 8(SP) SP. SP. #12Explanation / Answer
the assume directive directs the name of the stack segment to the assembler and the ss and sp register must be intialised in the program after the subroutine is called using the call instruction then the ip is incremented to the next instruction then the content of ip , cs and flag register are pulled automatically to the stack then the control is then transferred to the specific adress in the call instruction i.e to the starting address of the subroutine and there should be equal no of push and pop instructions in the sub routine that has to be executed so that sp contents at the time of calling the sub routine must be equal
a.the first subroutine instruction is that in which it stores the data which is been given then adds the two registers and then the stored data is kept in the next register
b. in the next sub routine call subtract then store the data in the next register and then load the next instuction in the sub program and call it from the subroutine
c.the last store instruction in the program in which thr addition operation is performed and in that the load byte instruction is been performed and adds the data and moves the data to next instruction
d.the last add instruction in which the pointer in the stack ss and sp are added and entered into one register and add them and return to the subroutine call
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.