# Print the Hello World phrase. # # Here we load the base address of the string # into register $a0, and use the print_string # syscall to print the phrase. .data hello: .asciiz "Hello" space: .asciiz " " world: .asciiz "World" newline: .asciiz "\n" .text main: # Function prologue -- even main has one subu $sp, $sp, 24 # allocate stack space -- default of 24 here sw $fp, 0($sp) # save caller's frame pointer sw $ra, 4($sp) # save return address addiu $fp, $sp, 24 # setup main's frame pointer # set up and print the string "Hello" la $a0, hello # Point to the string li $v0, 4 # syscall value for print_string syscall # set up and print the string " " la $a0, space # Point to the string li $v0, 4 # syscall value for print_string syscall # set up and print the string "World" la $a0, world # Point to the string li $v0, 4 # syscall value for print_string syscall # set up and print the string "\n" la $a0, newline # Point to the string li $v0, 4 # syscall value for print_string syscall done: # Epilogue for main -- restore stack & frame pointers and return lw $ra, 4($sp) # get return address from stack lw $fp, 0($sp) # restore the caller's frame pointer addiu $sp, $sp, 24 # restore the caller's stack pointer jr $ra # return to caller's code