Question

In: Electrical Engineering

PART 1: Design a program (using only native MIPS instructions, no pseudo instructions) that will prompt...

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

Solutions

Expert Solution

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);  
       }


Related Solutions

Do Not Use Pseudo Insturctions or li la instructions, etc... Write and test a MIPS program...
Do Not Use Pseudo Insturctions or li la instructions, etc... Write and test a MIPS program consisting of four functions. In the following descriptions, the symbol & means “address of”. void main(): The main function must 1) print your name 2) call the readData function 3) call count function 4) complete the program. The main function must set up all parameters before calling each of the functions. int readData (&array): The starting address of an array is passed to the...
Using MARS write a MIPS assembly language program to prompt the user to input two 32-bit...
Using MARS write a MIPS assembly language program to prompt the user to input two 32-bit integers X and Y (X and Y can be prompted separately or at the same time), get them from the user then store them in memory locations labeled X and Y respectively. The program then loads X and Y from the main memory to registers, calculates the sum of them (i.e. X + Y) and store the sum into a memory location labeled S....
Write a MIPS assembly language program that implements the following pseudo-code operation: result = x +...
Write a MIPS assembly language program that implements the following pseudo-code operation: result = x + y – z + A[j] x and y should be in reserved memory words using the .word directive and labeled as x and y. Initialize x=10 and y=200. Read in z from the console. Input the value -8. This is the value for z, not for –z. Store this value in memory with the label z. To begin, you could just initialize z to...
In C++ Please, using only the libraries given in this homework prompt, Write a program that...
In C++ Please, using only the libraries given in this homework prompt, Write a program that (1) prompts for two integers, (2) prints out their sum, (3) prints out the first divided by the second, and (4) prints out the natural log of the first number raised to the power of the second number. #include <iostream> #include <iomanip> using namespace std; int main() { <your answer goes here> return 0; }
For this assignment, you are required to write a MIPS program that reads its own instructions...
For this assignment, you are required to write a MIPS program that reads its own instructions and counts the number of occurrences of each type of instruction (R-type, I-type, or J-type). To accomplish this task, your program should execute the following steps: First, your program should load the address of its first instruction (0x400000) into a register, and initialize three separate instruction class counters to zero. Next, your program should enter a loop that reads each instruction from memory. For...
Translate the C function code below to the MIPS True Assembler Language code (machine instructions only)....
Translate the C function code below to the MIPS True Assembler Language code (machine instructions only). The function code should follow the conventions for MIPS function calls including passing parameters and returning results. Your function code must be written with the minimum number of machine instructions to be executed and without any use of MIPS pseudo-instructions. Myfunction(unsigned int a, unsigned int b, unsigned int c) { int i=0; while (a > c) { a /= b; i++; } return i;...
Focuses on the design, development, implementation, and testing of a Python program using Jupyter Notebook only...
Focuses on the design, development, implementation, and testing of a Python program using Jupyter Notebook only to solve the problem described below. You will write a program that simulates an Automatic Teller Machine (ATM). For this program, your code can have of user-defined functions only. However, the program must not call on any external functions or modules to handle any of the input, computational, and output requirements. Note, the program can be completed without the use of user-defined functions. Requirements:...
Design a simple program, using pseudocode, to implement the recursive formula you found in part (a)...
Design a simple program, using pseudocode, to implement the recursive formula you found in part (a) to compute numbers in the Fibonacci sequence. Describe in detail how your program implements the recursive formula. You may find it useful to discuss how it through a concrete example such as F(8) = 21.
I have to do the following MIPS coding assignment. Question 1 Write a MIPS program that...
I have to do the following MIPS coding assignment. Question 1 Write a MIPS program that meets the following requirements (NOTE: your program statements should follow the order of the requirements and each requirement should correspond to only one assembly instruction): Loads the hexadecimal equivalent of 23710 into register 13 using an immediate bitwise OR instruction Loads the hexadecimal equivalent of 183410 into register 17 using an immediate bitwise OR instruction Performs the bitwise AND operation on the operands stored...
Convert the following to machine code and then back to MIPS instructions: 1) a. addi $s0,...
Convert the following to machine code and then back to MIPS instructions: 1) a. addi $s0, $zero, -15 b. slt $t0, $s0, $s1 c. beq $t0, $zero, LEEQ d. j GRT
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT