# # example of use of procedures in subs.s # .globl main .text main: # # opening linkage (save return address) # addi $sp,$sp,-4 sw $ra,0($sp) # # print some lines # la $a0, line jal printline la $a0, another jal printline # # prompt for and then print some integers # # register use: # $s0 A # $s1 B # la $a0, promptA jal getint add $s0, $v0, $zero # la $a0, promptB jal getint add $s1, $v0, $zero # la $a0, printA add $a1, $s0, $zero jal printint # la $a0, printB add $a1, $s1, $zero jal printint # # closing linkage (get return address and restore stack pointer) # lw $ra,0($sp) addi $sp,$sp,4 jr $ra # # end of program # .end main # # area for variables and constants # .data line: .asciiz "hello world\n" another:.asciiz "greetings earthling\n" promptA:.asciiz "Enter an integer for A:\n" promptB:.asciiz "Enter an integer for B:\n" printA: .asciiz "Value of A: " printB: .asciiz "Value of B: "