Question

In: Computer Science

#use MPLAB X IDE # Question 1 for HW 3 # Your solution should implement the...

#use MPLAB X IDE
# Question 1 for HW 3
# Your solution should implement the following conditional statement:
#   if (A < 10)
#       D = C + 10
#   else if (A == 20)
#       D = C - B
#   else
#       D = C + B
        
    .global    main
    .data

### THESE VARIABLES ARE SIMPLY GIVEN VALUES TO START
###   WITH--CHANGE THEIR VALUES AND VERIFY YOUR PROGRAM
###   WORKS APPROPRIATELY IN ALL CASES
A:  .int    3
B:  .int    1
C:  .int    7
D:  .int    0
        
    .text
    .set       noreorder
    .ent       main

main:
    # Load variables into registers
    lw  $t0, A
    lw  $t1, B
    lw  $t2, C
    
    # Implement conditional statement described above
    # Make sure final result is in memory in variable "D"
        
# This code simply loops infinitely
spin:   
    j          spin
    nop

    .end        main    

Solutions

Expert Solution

The program required to have the logic in question is as below.

.global    main
    .data

### THESE VARIABLES ARE SIMPLY GIVEN VALUES TO START
###   WITH--CHANGE THEIR VALUES AND VERIFY YOUR PROGRAM
###   WORKS APPROPRIATELY IN ALL CASES
A:  .int    3
B:  .int    1
C:  .int    7
D:  .int    0
        
    .text
    .set       noreorder
    .ent       main

main:
    # Load variables into registers
    lw  $t0, A
    lw  $t1, B
    lw  $t2, C
    
    # Implement conditional statement described above
   bge $t0,10,next  # if a<10 execute below instruction else gonto lable next
   addi $t3,$t2,10  #D = C+10
   j done
  next: 
   bne $t0,20,else  #if a=20 execute below else go to else label
   sub $t3,$t2,$t1  #D = C-B
   j done
  else:
   add $t3,$t2,$t1  # D= C+B
    # final result is in memory in variable "D"
    done:
     sw $t3,D  #store value of D in memory  
    nop

    .end        main

Related Solutions

To develop a program for the PIC 16F84A using either MPLAB X IDE simulator software. T...
To develop a program for the PIC 16F84A using either MPLAB X IDE simulator software. T he PIC 16F84A has 8 LEDs connected to Port B. The program is to convert your student number (10 ASCII characters), taken in reverse order, one character at a time, to Gray code. Each converted character is to be displayed on 4 of the LEDs connected to Port B (B0 to B3) of the microcontroller. Further, each converted character will be displayed for 3...
Modify HW#1. C++ use,Write a multithreaded program that tests your solution to HW#1. You will create...
Modify HW#1. C++ use,Write a multithreaded program that tests your solution to HW#1. You will create several threads – for example, 100 – and each thread will request a pid, sleep for a random period of time, and then release the pid. (Sleeping for a random period approximates the typical pid usage in which a pid is assigned to a new process, the process executes and terminates, and the pid is released on the process’ termination).On UNIX and Linux systems,...
Write a Program using MPLAB IDE and XC8 compiler to do the followings: 1. When the...
Write a Program using MPLAB IDE and XC8 compiler to do the followings: 1. When the Program Starts it should send your Name and ID# to the Serial Port 2. Display the result on Tera Term. 3. Read PORTB buttons in an infinite loop (Main Loop which is the Read Buttons Loop), your program should not block when reading the Buttons except in De-bouncing.. But you need to de-bounce each button when pressed 3.1 If the user presses PORTB, RB0...
Control DC Using PIC18f46k20 and MPLAB IDE v8.8, write a program that can 1. Start and...
Control DC Using PIC18f46k20 and MPLAB IDE v8.8, write a program that can 1. Start and Stop the motor 2.Vary The motor Speed 3.Change the direction of the motor rotation 4.Display motor speed in OLED screen using c of MPLAB IDE v8.8 please test the code before posting
: EACH QUESTION SHOULD BE 1 TO 3 PAGES IN LENGTH TO COVER THE MATERIALS. USE...
: EACH QUESTION SHOULD BE 1 TO 3 PAGES IN LENGTH TO COVER THE MATERIALS. USE CITATIONS FROM YOUR RESEARCH AND THE CLASS MATERIALS. PROVIDE WORKS CITED PAGE. Question: what is meant by the term Jus Cogens. Why is it important to international law and what effect does it have on the making of international law.
Taylor Polynomial HW 1) Evaluate cos ( 2 π / 3 ) on your calculator and...
Taylor Polynomial HW 1) Evaluate cos ( 2 π / 3 ) on your calculator and using the first 4 terms of the TP for cos x. 2) Integrate cos ( x^3 ), from 0 to π / 6, using the first 3 terms of the TP for cos x. 3) Evaluate e^x at x = .4 on your calculator and using the first 5 terms of the TP for e^ x. 4) Integrate e^x3, from 0 to .3, using...
Your solution should be in good form with amounts clearly labeled and should use appropriate account...
Your solution should be in good form with amounts clearly labeled and should use appropriate account titles. Consider each of the transactions below. All of the expenditures were made in cash. The Edison Company spent $12,000 during the year for experimental purposes in connection with the development of a new product. On September 1, 2011, Tristar signed a $40,000 noninterest-bearing note to purchase equipment. The $40,000 payment is due on September 1, 2012. Assume that 8% is a reasonable interest...
Using your solution or your instructor's solution from the Module 8 ungraded practice exercise, implement a...
Using your solution or your instructor's solution from the Module 8 ungraded practice exercise, implement a unit test for the Pair class by adding a main method. Create three small constituent classes (I created PeanutButter, Jelly, and Mustard classes) and insert various combinations of them into an array of Pair objects. Thoroughly test the equals(), hashCode(), and toString() methods from the Pair class with your main method. Note: override the toString() method in each of your constituent classes so they...
Physics HW: Calculate: The Focus’ point should be to the right of the lens. 1) Without...
Physics HW: Calculate: The Focus’ point should be to the right of the lens. 1) Without the simulation, calculate the image position, height, and magnification for the following situation: Focal length (f) = 4 Object distance (do) = –10 Object height (ho) = 2 boxes Is the object real or virtual, is the image inverted or upright? 2) Without the simulation, calculate the image position, height, and magnification for the following situation: Focal length (f) = 4 Object distance (do)...
Using ECLIPSE IDE Write a Java Program to play your version of the Texas Pick 3...
Using ECLIPSE IDE Write a Java Program to play your version of the Texas Pick 3 Lottery. You will need to include the provided code given below in your program. Task:The program will prompt for a number between 0 and 999. Your program will display the number of attempts it took for the entered number to match a randomly generated number. In the main() method, declare an int named myPick3choice. Create a prompt for myPick3choice as "Enter your Pick 3...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT