OlveraeUNSW
返回题目列表
COMP1521

COMP1521 2020T2 Q1 · MIPS基础翻译

COMP1521 2020T2 Q1 · 10 marks · MIPS
知识点: MIPS基础翻译(MASM-B) · 次: 整数算术 · 难度: 基础
Topic: MIPS basics · Source: https://cgi.cse.unsw.edu.au/~cs1521/26T1/resources/practice_exams.html

一句话 / Summary: 读2个整数输出其和


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.

样例

stdin
5
8
期望输出
13
stdin
118
26
期望输出
144
stdin
42
42
期望输出
84
mipsy
14