Examples of using simulator system calls to do simple
console I/O:
hello.s,
echo.s,
echoint.s.
See Appendix A for more about the simulator and
its system calls.
Example of recursive procedure call (not in class):
factorial.s.
Sketch of some utility I/O functions (not in class):
consts.s
(constants for all files),
subs.s
(simple procedures for getting integer input and
printing things),
subs-use.s
(example of use).
To run the example, either load the files into the
simulator in the order given and start/run,
or combine them into a single file to load/run,
or use the spim-multifile script below,
thus:
spim-multifile consts.s subs.s subs-use.s
Script to mail files for homework submission
mail-files.
To use this script, put a copy in your directory
and use chmod u+x to make it executable.
You can then use it to mail me one or more files
containing source code, for example:
mail-files pgm1.s pgm2.s ....
It prompts for homework number and text to include as the
body of the message, and sends a Cc of the message
to your username at trinity.edu.
Script to combine files and pass to command-line version
of simulator
spim-multifile.
(This is meant to be useful if you want to split
a program into multiple .s files and
then recombine them at runtime and execute with
spim -f.)
To use this script, put a copy in your directory
and use chmod u+x to make it executable.
Sample execution: