Assignment Number: a6

Part 1

 

Filename: gcd.asm

Write a MIPS assembly language program, gcd.asm,to

1. Input two positive integers from the keyboard.

2. using a gcd function in your program, compute the gcd of the two positive integers.

3. The input parameters for the gcd function should be passed in $a0 and $a1. The output parameter should come back in $v0.

4. Print the following message:

The gcd of a and b is g.

 

The following is some sample I/O.

 

Input first positive integer: 4

 

Input second positive integer: 6

 

The gcd of 4and 6 is 2

 

Input first positive integer: 48

 

Input second positive integer: 30

 

The gcd of 48 and 30 is 6

 

Input first positive integer: 236

 

Input second positive integer: 952

 

The gcd of 236 and 952 is 4

 

Part 2

 

Filename: singleasmd.asm

Write a MIPS assembly language program, singleasmd.asm, to

 

1. Input two single numbers from the keyboard.

 

2. Input an operation, +, -, *, or /.

 

3. Output the statement and the result, e.g.,1.23   -

 

4.567 = -3.337

 

4.Prompt to see if the user wants to do another calculation, e.g.,

Another calculation? (y/n)

The following is some sample I/O.

Input first single number: 1.23

Input second single number: 4.567

Input operation: -1.23 –4.567 = -3.337

Another calculation? (y/n) y

Input first single number: -9.8

Input second single number: .76

Input operation: *-9.8 * .76 = -7.448

Another calculation? (y/n) n

    • 11 years ago
    A+ Work
    NOT RATED

    Purchase the answer to view it

    blurred-text
    • attachment
      assignment_6.zip