Question

Stack Operation 10. (10 pts.) Show the contents of the stack and affected registers at the two marked points in the execution

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Initial Values for registers are :

When First instruction (PUSH{R2,R3} is executed :

Value of SP(stack pointer) is decreased by 4

now SP have value 0x20000FFC then value in Register R2 is pushed into stack at the Memory Address 0x20000FCC(value represented by SP)

after that value of SP is decreased by 4 and became 0x20000FF8 now value of R3 register is pushed at stack at Memory Address 0x20000FF8.

When Second instruction(ADD R4,R1,R0;) is executed it adds value of R1 and R0 to R4.

what ADD instruction do is take value from second place(here R1) and third place(here R0) to do arithmetic(adding) then store the result at first place(here R4). after execution of this instruction value of R1 and R0 remains same as before 1 and 0 respectively but value of R4 is changed to sum of 1 and 0. so value of R4 became 1 from 4.

At the point A values are :

What POP instruction do is read the value from Memory Address to the Register and then increase SP value.

When third instruction is executed(POP{R5,R6}):

value at memory address 0x20000FF8(represented by SP) is copied to R5 then value of SP is increased by 4 and became 0x20000FFC now value at memory address 0x20000FFC is copied to R6 and value of SP is increased by 4. now value of R5 is 3, R6 is 2 and SP is 0x20001000.

Forth instruction ADD R5,R5,R4 stores the value got from sum of R5(value at this point 3) and R4(value at this point 1) at R5. now value of R5 becomes 4.

After Fifth instruction ADD R6,R6,R5 value stored by R6 became 6 by adding value from R6(before instruction executes 2) and R5(value 4)

Sixth instruction PUSH{R4-R6} pushes value of registers R4,R5andR6 to the Stack.(to the Memory Address by decreasing the value of SP) first value of SP is decrease to 0x20000FFC and value of R4(1) is copied to Memory Address 0x20000FFC, then value of SP is decreased to 0x20000FF8 and value of R5(4) is copied to Memory Address 0x20000FF8, later value of SP is decrease to 0x20000FF4 and value of R6(6) is copied to Memory Address 0x20000FF4.

The last instruction SUBS R0,R0,R1 : subtracts the value of R1(1) from value of R0(0) and stores the result into R0(-1).

what SUBS do is stores the result at first place(R0) got from subtracting value of third place(R1) from second place (R0).

SUBS               R0                    R0               R1           means

operator     destination           operand1        operand2

At the point B values are :

Program only explores first 3 memory address so the remaining value of memory address is not known. it can contain any possible value.

Add a comment
Know the answer?
Add Answer to:
Stack Operation 10. (10 pts.) Show the contents of the stack and affected registers at the two marked points in the exe...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Show the stack contents, registers contents and the stack pointer value for each step of the...

    Show the stack contents, registers contents and the stack pointer value for each step of the following code: Mov R5,#25H Mov R6,#15H Mov R1,#20H Push 5 Pop 2 Mov R2, #55H Push 2 Push 6 Pop 5 9

  • Assume the stack pointer (SP) is initialized to 0x20000000 . Registers RO, R1, R2 and R12...

    Assume the stack pointer (SP) is initialized to 0x20000000 . Registers RO, R1, R2 and R12 are initialized to 2, 3, 8 and 15 respectively. Answer the following: Show the content of the stack and the SP after the following sequence of operations. PUSH (R12} PUSH {R1-R2} PUSH (RO) Answer format example=> {1,2,3,4} if 1,2,3,4 are values in stack and with no spaces. Answer: Does the following cause a data hazard for the 5-stage LEGV8 pipeline? i1: ADD XO, X1,...

  • Section B - ARM Assembly Language (25 marks) An ARM instruction set summary is provided at...

    Section B - ARM Assembly Language (25 marks) An ARM instruction set summary is provided at the end of this paper 1. (5 marks) Consider the following assembly instruction STMFD r13!, (r5-6} Before executing this instruction, registers hold the following values: Register Value Register r9 Value r4 0x00400040 0x00000000 r5 r10 0x11223344 0x00800080 r6 0x55667788 r11 0x10001000 r7 0x99aabbcc r12 0x20002000 r8 exddeeff00 r13 ex40004000 What memory locations are affected after executing the above instruction? In a table, with a...

  • Show a complete bottom-up parse, including the parse stack contents, input string, and action for the...

    Show a complete bottom-up parse, including the parse stack contents, input string, and action for the string below using the parse table String: (id+id) * id Grammar(language) : E -> E + T |E * T | T T -> (E) | id Parse table: Then show a rightmost derivation for the string above and show how the bottom up parse correctly finds all of the handles. R-reduce S-Shift - Error id S4 S5 S6 S7 Accept R1 R1 R1...

  • a)Complete the following LC-3 PUSH routine. Assume R6 is the stack pointer, st grows towards 0...

    a)Complete the following LC-3 PUSH routine. Assume R6 is the stack pointer, st grows towards 0 and each element of the stack takes four memory locations PUSH ADD R6, R6, STR RO, R6, lowing operations, what are the contents of the stack? Show what the ck contains after each operation and the final stack contents. Multiply routine takes two operands off the stack, multiplies and pushes the result back on the stack push 2 push 2 multiply If the stack...

  • The classic five-stage pipeline MIPS architecture is used to execute the code fragments in this problem....

    The classic five-stage pipeline MIPS architecture is used to execute the code fragments in this problem. Assume the followings: • The architecture fully supports forwarding, • Register write is done in the first half of the clock cycle; register read is performed in the second half of the clock cycle, • Branches are resolved in the third stage of the pipeline and the architecture does not utilize any branch prediction mechanism, • Register R4 is initially 200. L1: lw lw...

  • help Question 11 The classic five-stage pipeline MIPS architecture is used to execute the code fragments...

    help Question 11 The classic five-stage pipeline MIPS architecture is used to execute the code fragments in this problem. Assume the followings: • The architecture fully supports forwarding, • Register write is done in the first half of the clock cycle; register read is performed in the second half of the clock cycle, • Branches are resolved in the third stage of the pipeline and the architecture does not utilize any branch prediction mechanism, • Register R4 is initially 200....

  • . U 8. (15 pts) Assuming the code fragment below is executed by the classic 5-stage...

    . U 8. (15 pts) Assuming the code fragment below is executed by the classic 5-stage MIPS architecture, answer the following questions. Ll: lw RI, O (R5) // 11 add R2, Ri, 20 // 12 lw R3, 0(R6) // 13 add R3, R2, R3 SW R3, 0(R5) addi R4, R4,-4 // 16 addi R5, R5,4 // 17 addi R6, R6,4 // 18 bne R4, RO, L1 // 19 a. (5 pts) Assuming R5 holds the address of array A, R6...

  • Assignment 4: Answer the following questions with reference to the assembly program below. Before the code...

    Assignment 4: Answer the following questions with reference to the assembly program below. Before the code is executed, the initial content of memory and registers is shown in the figure below memory 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 address Use BIG ENDIAN, and 0x2000.0000 0x2000.0001 0x2000.0002 show all steps register 0x2000.0000RO Ox2000.0003 0x2000.0004 0x2000.0005 0xFFFF.FFFF R2 ox2000.0006 0x1234.5678 R3 0x2000.0007 Ox0000.0000 R1 LDRH R1, [R0 , #2]! LDRH R2 , [R0 , #2)! ADD R3, R1, R2 STR...

  • Implement the following statements using MS430 assembly instructions. You may use more than one, ...

    Implement the following statements using MS430 assembly instructions. You may use more than one, but you should minimize the number of instructions required. You can use both native and emulated instructions. Use hex notation for all numbers 1. (a) Move the word located in register R14 to R15 (b) Increment the word in R6 by 2. (c) Perform a bitwise ANDing of the word located at address 0x0240 with the datum in R15, placing the results in R15. (d) Rotate...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT