Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PART 1: Design a program (using only native MIPS instructions, no pseudo instruc

ID: 2293747 • Letter: P

Question

PART 1: Design a program (using only native MIPS instructions, no pseudo instructions) that will prompt user to enter three decimal numbers. Each decimal number will not exceed six digits The program can't ask user how many digits will be entered. Both numbers must be stored in memory as NULL terminated strings. The first number must be stored at the memory address 0x10000000. The second number must be stored in the memory 0x10000008. The third number must be stored at the memory 0x10000010. The user may enter a comma(e.g 123,456) when entering the numbers, but not required. If a comma is entered, it should not be stored as part of the string.

PART 2: write a MIPS assemlby language subroutine called sum that accepts arguments in $a0 and $a1. The arguments are the address of the two NULL terminated strings. The subroutine should convert each of the two strings to intgers, and return the sun in $v0. Note that the strings must NOT be modified by the routine! Your subroutine must adhere to the MIPS software conventions.

THE TWO PARTS MUST BE SEPERATED BY:

#_CUT_HERE

Explanation / Answer

part-1:-

   import java.io.*;
   class OddEvens
   {
   public static void main(String args[])throws IOException
       {
       int input=0,evenNum=0,oddNum=0;
       boolean flag=true;
       BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
       System.out.println("Enter an integer:");
       while(flag==true)
           {
           input=Integer.parseInt(br.readLine());
           if(input%2==0)
               evenNum++;
           else
               oddNum++;
           boolean valid=false;
           while(valid!=true)
               {
               System.out.println("Enter more integers(Y/N)?");
               char ch=(char)br.read();
               if(ch=='N')
                   {
                   flag=false;
                   valid=true;
                   }
               else if(ch=='Y')
                   valid=true;
               else if(ch!='Y')
                   valid=false;
               }
           }
       System.out.println("Number of even integers:" + evenNum);
       System.out.println("Number of odd integers:" + oddNum);      
       }
   }

#_CUT_HERE

Part-2:-

void digits(int number)
       {
       int numOfDigits=0;
       while(number!=0)  
           {
           number=number/10;
           numOfDigits++;
           }
       System.out.println("Number of digits=" + numOfDigits);  
       }