next up previous
Next: 7 Getting started Up: The Mintel Smalltium Microprocessor Previous: 5.3.3 Conditionals

6 Traps

  Every computer system has an operating system that runs it. This operating system provides programs with services that most programs need, such as I/O and file manipulations. The way programs communicate with the OS is through the use of a trap. A trap is an instruction that the program uses to give up control of the computer to the OS, so that the OS can perform some function. When the OS finishes its job, it returns to the place in the program where the trap instruction was and continues.

For the purposes of the Smalltium simulator, we are not going to run an operating system. Instead, the simulator itself will handle the various traps as though they were a part of the hardware. In a real processor, the functionality of the traps would be completely independent of the hardware, but without them you cannot write a program that does anything interesting.

The Smalltium allows a total of 16 different traps (numbered 0 through 15). Only the first four traps have been specified. These four traps deal with I/O. In the Smalltium, a trap may take two register arguments. The registers contain data for the trap to use in performing its function.

Here is the list of traps:

To use a trap in assembly language, you use the TRAP instruction (see section 5.1), and give the trap number as the first argument. Look at the example programs for examples of how to use traps.


next up previous
Next: 7 Getting started Up: The Mintel Smalltium Microprocessor Previous: 5.3.3 Conditionals

James Clingenpeel
Thu Feb 29 18:00:38 MST 1996