13.07.2015 Views

The Midterm Solution - Suraj @ LUMS - Lahore University of ...

The Midterm Solution - Suraj @ LUMS - Lahore University of ...

The Midterm Solution - Suraj @ LUMS - Lahore University of ...

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

29.[10 marks]SP(StackPointer)Consider that an interrupt takes place when themicroprocessor is executing an instruction stored atlocation N. <strong>The</strong> status flags at this instant contain thevalue ABCDh. <strong>The</strong> corresponding interrupt serviceroutine (ISR) is stored in memory starting from location Xand X + C (both inclusive)a) What is the address <strong>of</strong> the instruction that will beexecuted after the interrupt occurs. [2]XXstartb) Where will the program branch to after the completion<strong>of</strong> the interrupt? [2]N + 1c) How will the microprocessor know where to branchafter the completion <strong>of</strong> the interrupt? [3]X+C endPrior to branching to the ISR the microprocessorstores the address <strong>of</strong> the current value <strong>of</strong> theInstruction pointer onto the stack. On completion <strong>of</strong>the subroutine it pops this address <strong>of</strong>f the stack andloads this into the instruction pointer and thusbranches back to the correct location.UserProgramNMAINMEMORYd) What will happen if a second interrupt takes placewhile the first one is being serviced? [3]If a second interrupt took place, then if it were <strong>of</strong>higher priority and the interrupt process was enabledthe microprocessor would once again push the currentcontext onto the stack and branch to the new ISR andon completing it branch back and complete the firstISR by popping <strong>of</strong>f the context from the stack. If theinterrupt process was disabled or if the new interruptwas <strong>of</strong> a lower or the same priority as the currentinterrupt it would remain pending.Page 16 <strong>of</strong> 16

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!