Assembly Notes

Please put all of your .data and .space declarations at the beginning of the program. It makes the code much more readable!
Always use LDCH and STCH when dealing with buffers for characters. The keyboard interrupt will pack the characters in a way that requires use of LDCH to succesfully extract all the characters.

To call a function:

push any registers with useful content
push parameter values in reverse order
CALL function

After calling a function:

ADD SP, total size of parameters pushed
pop to recover any saved registers

First thing a function does:

PUSH FP save callers frame pointer
LOAD FP, SP set up own frame pointer
SUB SP, total size of local variables

Inside a function, counting from 1 not zero:

Nth parameter is at FP+(N+1)
Nth local is at FP-N

Last thing a function does

put result if any in R1 //Doesn't have to be R1, but be consistent
LOAD SP, FP get rid of all local variables
POP FP recover callers frame pointer
RET