created: 08/05/01; small changes: 03/17/03

# CHAPTER 22 — SPIM Trap Handler

Up until now, your programs have been running with SPIM used as a "bare machine" — a computer with no machine code in it but your own. Most computer systems run under the control of an operating system. Application programs use the services of the operating system to do input and output and other system tasks.

SPIM does not have an operating system, but it can run a small trap handler — a set of services that is a great help in writing assembly programs.

#### Chapter Topics:

- The `syscall` instruction.
- SPIM trap handler.
- Trap handler services:
  - halt program
  - print string
  - read string
  - print integer
  - read integer
- Hello World example.
- Library Fine example.

### QUESTION 1:

In an actual bare machine (real hardware) do you suppose that it is easy to write a character to the terminal?