The following program is the final result of this chapter. Make sure that the file utils.asm is in the same directory as the program Program5-9.asm. Bring Program5-9.asm into the edit window in MARS, assemble it, and run it.
Program 5-6: Final program to prompt for, read, and print an integer # File: Program5-9.asm # Author: Charles Kann # Purpose: To illustrate implementing and calling a subprogram named PrintNewLine. .text main: # read an input value from the user la $a0, prompt jal PromptInt move $s0, $v0 # print the value back to the user jal PrintNewLine la $a0, result move $a1, $s0 jal PrintInt # call the Exit subprogram to exit jal Exit .data prompt: .asciiz "Please enter an integer: " result: .asciiz "You entered: " .include "utils.asm"
Note that by using subprogram abstraction how much easier this program is to understand than the one at the start of the chapter. It is beginning to look like the HLL code most readers are already familiar with.