go to previous page   go to home page   go to next page hear noise

Answer:

li  $v0,4          # code 4 == print string
la  $a0,message    # $a0 == address of the string
syscall            # Ask the operating system to 
                   # perform the service.
    . . . .

         .data
message: .asciiz      "Intruder Alert!\n"

The Traditional Example

You are now ready to see the program you probably expected to see in Chapter One. The following program prints the string, then calls the exit service.

# hello.asm
#
        .text
        .globl  main
main:
        li      $v0,4       # code 4 == print string
        la      $a0,string  # $a0 == address of the string
        syscall             # Invoke the exception handler.

        li      $v0,10      # code 10 == exit
        syscall             # Halt the program.

        .data
string: .asciiz      "Hello SPIM!\n"

The string is printed to the monitor window of the simulator. The program is complete, and can be copied into a source file and run as is. But see the next page first.


QUESTION 5:

On a real (hardware) computer, what is the exception handler?