# hello.s # This is our first program in the MIPS assembly language. # Let's print out a string and number. # To perform I/O, we need to make a system call. This usually involves # writing 3 instructions - # first, select the type of I/O function by specifying a value for $v0 # (list of possible codes is given in your book on page A-49) # second, initialize $a0 to the argument you want # third, use syscall instruction to do the I/O action # Notes on instructions: # li = put a constant into a register # la = put the address of an array/string into a register # move = copy the value from one register into another .data # Data segment has array/string declarations msg: .asciiz "Hello, world.\n" msg2: .asciiz "Goodbye.\n" .text # Text segment has instructions. main: # You have to label the start of program. li $v0, 4 # print the message la $a0, msg syscall li $s1, 12 # Find the sum of 2 numbers. li $s2, 23 add $s3, $s1, $s2 li $v0, 1 # print an integer move $a0, $s3 syscall li $v0, 10 # end of program syscall