Starting from:

$30

CSCI231 Lab 6-Solved


1. Write a program in MIPS assembly language that prompts the user for two integers and prints out the sum of these integers to the console. Recall that the largest positive integer and the smallest negative integer that can be stored in one word is 2147483647 and -2147483648, respectively. Your program may terminate with errors if the user enters an invalid integer or the sum of the integers overflows. Therefore, if an exception occurs, your program should not terminate with errors, but start from the beginning again.

For example, if the user enters an integer bigger than 2147483647 (or smaller than -2147483648), your program should print out“Try again!” and start prompting for two integers again. Likewise, if the user enters two valid integers but the sum is bigger than 2147483647 (or smaller than -2147483648), your program should print out “Try again!” and start prompting for two integers again.

Hint: You may want to use the address of the beginning of the program, i.e.,00x00400000.

More products