Tue, 26 Nov 2013, 20:06

My students, 

I thought the answer to this was clear, both from my lectures and the
examples in the textbook, but just in case, I am sending it to everyone.
If you know that subroutines are written as part of your one file, feel
free to delete and move on.

A student writes:

> Dear Professor Patt,
> I am Travis a first year in your 306 class. For the fourth program if we 
> have subroutines, do we create a separate file for the subroutine and you 
> will load both the subroutine file and the nim.asm file when grading?
> Sincerely, 
> <name withheld to protect a student who did not look at examples in the book> 

No!  The subroutines should be written as part of a single .asm file, and
assembled as a single file also.

Where you put the subroutines is, of course, up to you.  Most people find it
useful to put their subroutines right after the TRAP x25 instruction, but it
is not necessary, as long as it comes after an instruction that does not
allow executing the next instruction in sequence in your program.

For example, suppose you have three subroutines in your program, their
starting addresses are ONE, TWO, and THREE.  If you wish your program 
could look like:

ONE     <<code>>
	TRAP x25
TWO     <<code>>
THREE   <<code>>

Note that subroutine ONE comes immediately after an unconditional branch,
and subroutines TWO and THREE come after the HALT instruction.

Good luck finishing this before Thanksgiving.  Have a great weekend.
See you in class tomorrow, either physically or virtually!

Yale Patt