The instruction below pushes register R4 on the stack Tire v

The instruction below pushes register R4 on the stack. Tire values of R4 and SP prior to the push operation are shown below. push. w R4; R4=0x34CD, SP=400 What is the value of SP after the push instruction executes? At w hat address is R4 pushed in the stack? Show the content of each address that the value occupies. Is there any wasted memory that\'s reserved on the stack? Pail b) Repeat the questions above for the case where the push instruction does a byte operation, that is: (push. b R4).

Solution

a) Value if SP after push instruction executes is the Stack pinter SP is decremented by 4 units . Value =396

Decrements the stack pointer and then stores the source operand on the top of the stack. The address-size attribute of the stack segment determines the stack pointer size (16 bits or 32 bits), and the operand-size attribute of the current code segment determines the amount the stack pointer is decremented (2 bytes or 4 bytes). For example, if these address- and operand-size attributes are 32, the 32-bit ESP register (stack pointer) is decremented by 4 and, if they are 16, the 16-bit SP register is decremented by 2. (The B flag in the stack segment\'s segment descriptor determines the stack\'s address-size attribute, and the D flag in the current code segment\'s segment descriptor, along with prefixes, determines the operand-size attribute and also the address-size attribute of the source operand.) Pushing a 16-bit operand when the stack addresssize attribute is 32 can result in a misaligned the stack pointer (that is, the stack pointer is not aligned on a doubleword boundary.

b) The stack pointer is usually a register that contains the top of the stack. The stack pointer contains the smallest address x such that any address smaller than x is considered garbage, and any address greater than or equal to x is considered valid.

You can push one or more registers, by setting the stack pointer to a smaller value (usually by subtracting 4 times the number of registers to be pushed on the stack) and copying the registers to the stack.

b) Here the register physical address is 0X34CD . This is the address where the R$ is pushed on to the stack

c) n a stack, only one end is accessible for principal operations but, in a ... keep track of the top of the stack, there is no wastage of memory space.

Partb)In push instruction using byte operation , the symbol (+ or -) will first move into the stack and then operands (here bytes) initially the stack pointer increments after pusing the symbol then increments after pushing operands and then the value of the operation will be a postfix operation . Suppose we push a+b , then value is ab+ . The stack pointer remians the same .

 The instruction below pushes register R4 on the stack. Tire values of R4 and SP prior to the push operation are shown below. push. w R4; R4=0x34CD, SP=400 What

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site