Trap Instruction
Trap can be used for various system calls and service routines.
This means Trap can handle Input/Output (I/O).
Trap transfers over control to the operating system then returns control back to the user.
1111 0000 vvvv vvvv
vvvv vvvv: Trap Vector is one of several options:
- x20 (hex); 0010 0000 (binary) - 1111 0000 0010 0000
- GETC: Reads a single character in
- Writes single ASCII char to R0
- x21 (hex); 0010 0001 (binary) - 1111 0000 0010 0001
- OUT: Outputs a single char from R0 to the console
- x22 (hex); 0010 0010 (binary) - 1111 0000 0010 0010
- PUTS: Prints a string to the console(prints contiguous chars from an address of value of R0 until a terminating character is encountered)
- x23 (hex); 0010 0011 (binary) - 1111 0000 0010 0011
- IN: Print prompt to console, read and echo character from keyboard
- x25 (hex); 0010 0101 (binary) - 1111 0000 0010 0101
- HALT: Halt(Stop) the Program