Show the stack and stack pointer for each line of the follow

Show the stack and stack pointer for each line of the following program. ORG 0 MOV R0, #66H MOV R3, #7FH MOV R7, #5 DH PUSH 0 PUSH 3 PUSH 7 CLR A MOV R3, A MOV R7, A POP 3 POP 7 POP 0

Solution

Note This

MOV statement does not effect Stack pointer

PUSH statement increment stack pointer to 2 address

POP   statement decrement stack pointer by 2 address

PUSH 0 //stack+2
PUSH 3//stack+2
PUSH 7//stack+2

LET suppose stack pointer is at 01

ORG 0
MOV R0, #66H ;SP = 01, no effect on stack
MOV R3, #7FH ;SP = 01, no effect on stack
MOV R7, #5DH ;SP = 01, no effect on stack
PUSH 0 ;SP = 03,
PUSH 3 ;SP = 05
PUSH 7 ;SP = 07
CLR A ;clear the accumulator

MOV R3, no effect
MOV R7, no effect
POP 3   SP=05
POP 7 SP=03
POP 0 SP=01

 Show the stack and stack pointer for each line of the following program. ORG 0 MOV R0, #66H MOV R3, #7FH MOV R7, #5 DH PUSH 0 PUSH 3 PUSH 7 CLR A MOV R3, A MOV

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site