Sat, 5 Oct 2013, 04:00



My students,

The TRAP x25 instruction still seems to be confusing some students so I am
sending this out. 

A student writes:

 
> I take it that the program is supposed to end on the address xFD79 
> regardless?
> 
> <<name withheld to protect the student wanting to know where everything ends>>


That was his entire email.  No "Dear Dr. Patt," or even "Hello Dr. Patt."
No further explanation.  Just the one sentence copied above, and his 
signature.  So, I am not exactly sure what he is asking, but hopefully 
this will help.

Your program ends with the TRAP x25 instruction.  This is the LAST
instruction your program executes.  Anything you put after that will not
be treated as instructions since the TRAP x25 will instruct the operating
system to halt the computer, guaranteeing that the PC will not contain the 
addresses of what you put after the TRAP x25 instruction.

That does not mean the TRAP x25 instruction is the last instruction the
computer will execute before the computer halts.  Indeed, your TRAP x25
instruction specifically asks the operating system (Windows, Linux, LC3-OS,
whatever!) to execute additional instructions on behalf of you to stop
the computer.  These instructions are collectively referred to as the
TRAP x25 SERVICE ROUTINE.

As to where this service routine ends, i.e., the last instruction executed
before the computer actually halts, the truth is I have not looked at that 
TRAP service routine that the operating system executes in awhile, so I do 
not remember.  It could very well be located at address xFD79.  I can ask 
one of my TAs to look and see, and let you know.  

Good luck on the midterm.

Yale Patt