assemblylc3

How to return from HALT in LC3?


This picture is from the book "introduction to computing systems 3d edidtion".

enter image description here

I have highlighted in red what I am wondering about. Could you please tell me the answer to the authors question?


Solution

  • It is indeed a trick question.  After that bit in the Machine Control Register is cleared, instruction processing ceases because the clock is stopped — so the answer is none, no instruction or trap can be used to restart the system.

    Only an external mechanism can restart the clock once halted.

    If an external mechanism were to restart the clock (presumably setting that bit in the MCR?), then the HALT trap will return to its caller — but calling programs absolutely do not expect this to happen!  There's generally no more code after a HALT trap, so no instructions to run, and often even, there's data there after a HALT (and it is nonsense to execute data) because of programmer's expectation that a HALT trap doesn't return.

    The most reasonable way to restart the clock is to use a complete restart mechanism, which would boot the machine and load some program to run at its starting entry point.