← Back to problems
UNSW COMP1521 · easy

COMP1521 2020T2 Q1 — MIPS basics

COMP1521 2020T2 Q1 · 10 marks · MIPS Topic: MIPS basics · Source: https://cgi.cse.unsw.edu.au/~cs1521/26T1/resources/practice_exams.html

Summary: Read 2 integers and print their sum

You have been given practice_q1.s , a MIPS assembler program that reads one number and then prints it.

Add code to practice_q1.s to make it equivalent to this C program:

// print the sum of two integers

#include <stdio.h>

int main ( void ) { int x , y ;

scanf ( "%d" , & x ); scanf ( "%d" , & y ); printf ( "%d \n " , x + y );

return 0 ; }

In other words, it should read 2 numbers and print their sum.

For example:

1521 mipsy practice_q1.s 5 8 13 1521 mipsy practice_q1.s 118 26 144 1521 mipsy practice_q1.s 42 42 84

No error checking is required.

Your program can assume its input always contains two integers, and only two integers.

You can assume the value of the expression can be represented as a signed 32 bit value. In other words, you can assume overflow/underflow does not occur.

Your solution must be in MIPS assembler only.

MIPS (mipsy)