Ask your own question, for FREE!
Engineering 19 Online
OpenStudy (anonymous):

LXI SP,EFFFH CALL 3000H : : : 3000H:LXI H,3CF4H PUSH PSW SPHL POP PSW RET What will be the value in SP after the last instruction?(Please explain it)

OpenStudy (anonymous):

please explain it,is there anybody present

OpenStudy (anonymous):

LXI SP, EFFFH it is used to initiate the stack , the content is moved to the stack pionter which is the address of the top of the stack, CALL , 3000H , it will move the program counter to the 3000H address , before it the next address of the program counter ie the address next to the CALL instruction will be pushed into the stack thus stack pointer is decremented by 2 LXI H , 3CF4H this instruction again used to load an immediate data to the HL pair, PSW stands for the AF register (accumulator - flag ) PUSH PSW it will push tkhe content of the AF to the stack pointer thus Stack is again decremented by 2 SPHL will load the content of the HL pair to the Stack pointer thus the stack pointer will mov to the address given by the content of the HL ie 3CF4H POP PSW will retun some garbage value to the AF since it the stack pointer has moved to a different address and we are uncertain of the value being stored there and the stack is decremented by 2 thus the value of the SP is (3CF4H-0002H)=3CF2H ; when the subroutine is over the main routine function is defined by the address being stored in the Stack , thus the program will return to the address obtained from the content of the addresses (3CF2H & 3CF1H) whose data is again unknown and thus the program will start at an unknown address.

OpenStudy (anonymous):

what will be the content of SP at the end of execution

OpenStudy (anonymous):

Both PUSH and POP can't decrement SP PUSH will decrement while POP will increment

OpenStudy (anonymous):

yup i did a mistake the content of SP wud be 3CF6H...

OpenStudy (anonymous):

(3CF4H+0002H)=3CF6H

OpenStudy (anonymous):

POP will add 2 and then RET again will add 2 to SP,So content of SP would be 3CF8

OpenStudy (anonymous):

RET is never going to add...to the content of the SP only the instructions which are being used for branching operation will automatically adds to the content so that it can be used again ...for loading in the program counter once the subroutine has ended......

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!