1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Zarrin [17]
2 years ago
6

Write an assembly subroutine that check if a number is in the interval of [0, 10] and return 1 if the number is in this interval

and 0 otherwise. Call this subroutine to check if each integer in an array in the memory is in this interval and write the results of all numbers into another array in the memory
Computers and Technology
1 answer:
Setler79 [48]2 years ago
5 0

Answer:

.data

array: .word 1,3,5,7,9,11,13,15,17,19

result: .word 0,0,0,0,0,0,0,0,0,0

.text

  la $s0, array

  la $s1, result

  addi $t0, $zero, 0

  INTERVAL:  bge $t0, 10, END

     sll $t1, $t0, 2

     add $t2, $s0, $t1

     lw $t2, 0($t2)

     jal LIMIT

     IF:    bne $a0, 1, ELSE

        add $t3, $s1, $t1

        sw $t2, 0($t3)

     ELSE:

     addi $t0, $t0, 1

     j INTERVAL

  END:    

  addi $v0, $zero, 10

  syscall

  LIMIT:  

     addi $a0, $zero, 0

     START: bge $t2, 0, NEXT

        b ENDLIMIT

     NEXT:  ble $t2, 10, SET

        b ENDLIMIT  

     SET:   addi $a0, $zero, 1

     ENDLIMIT:

     jr $ra

Explanation:

The assembly source code is used to create a subroutine called "INTERVAL" that checks if a number from an array is in a range of 1 to 10. The program returns 1 if the condition is met but 0 if otherwise.

You might be interested in
P**nhub or x-videos or other
Colt1911 [192]
U shouldnt be watching them, Idc how old u are.
3 0
3 years ago
You are working on a ticketing system. A ticket costs $10. The office is running a discount campaign: each group of 5 people is
cupoosta [38]

Answer:

Explanation:

The following program is written in Java. It takes 5 inputs of int values for the ages of each member in the group. Then it loops through all of the ages and chooses the youngest age. Finally, it applies that age as a discount to the final price which would be $50, outputting the final discounted price. The output for the test case provided can be seen in the attached picture below in red.

import java.util.Scanner;

class Brainly

{

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       int[] person = new int[5];

       System.out.println("Enter age of individual 1: ");

       person[0] = in.nextInt();

       System.out.println("Enter age of individual 2: ");

       person[1] = in.nextInt();

       System.out.println("Enter age of individual 3: ");

       person[2] = in.nextInt();

       System.out.println("Enter age of individual 4: ");

       person[3] = in.nextInt();

       System.out.println("Enter age of individual 5: ");

       person[4] = in.nextInt();

       int youngest = person[0];

       for (int x = 0; x < person.length; x++) {

           if (person[x] < youngest) {

               youngest = person[x];

           }

       }

       double discount = 1 - (((double)youngest) / 100);

       double output = 50 * discount;

       System.out.println("Total Price: " + output + " the youngest is " + youngest);

   }

}

8 0
2 years ago
Write a program that prompts the user to enter two characters and display the corresponding major and year status. The first cha
nydimaria [60]

Answer:

  1. import java.util.Scanner;  
  2. public class Main {
  3.    public static void main(String[] args) {
  4.        Scanner input = new Scanner(System.in);
  5.        System.out.print("Please enter two characters: ");
  6.        String inputStr = input.nextLine();
  7.        if(inputStr.charAt(0) == 'B' || inputStr.charAt(0) == 'b'){
  8.            System.out.println("Biology");
  9.        }
  10.        else if(inputStr.charAt(0) == 'C' || inputStr.charAt(0)== 'c'){
  11.            System.out.println("Computer Science");
  12.        }
  13.        else if(inputStr.charAt(0) == 'I' || inputStr.charAt(0) == 'i')
  14.        {
  15.            System.out.println("Information Technology and Systems");
  16.        }
  17.        else{
  18.            System.out.println("Invalid major");
  19.        }
  20.        int num = Character.getNumericValue(inputStr.charAt(1));
  21.        if(num >= 1 && num <= 4){
  22.            switch (num){
  23.                case 1:
  24.                    System.out.println("freshman");
  25.                    break;
  26.                case 2:
  27.                    System.out.println("sophomore");
  28.                    break;
  29.                case 3:
  30.                    System.out.println("junior");
  31.                    break;
  32.                case 4:
  33.                    System.out.println("senior");
  34.                    break;
  35.            }
  36.        }
  37.        else{
  38.            System.out.println("Invalid year status");
  39.        }
  40.    }
  41. }

Explanation:

The code consists of two main parts. The part 1 is to validate the input major and print out the major according to the input character (Line 10 -22). If the input character is not matched with the target letters, a message invalid major will be displayed.

The part 2 is to validate the year status to make sure it only fall within the range of 1-4  (Line 26 -45). If within the range, the program will display the year major accordingly. If not a message invalid year status will be displayed.

4 0
3 years ago
It takes Mike 18 minutes to finish reading 4 pages of a book. How long would it take for him to finish 30 pages ?​
miss Akunina [59]

Answer:

135 minutes or and 2 hrs and 15 minutes

6 0
3 years ago
Define a class named ComparableSquare that extends Square (defined above) and implements Comparable. Implement the compareTo met
Alexxx [7]

Answer:

/*********************************************************************************

* (The ComparableCircle class) Define a class named ComparableCircle that        *

* extends Circle and implements Comparable. Draw the UML diagram and implement   *

* the compareTo method to compare the circles on the basis of area. Write a test *

* class to find the larger of two instances of ComparableCircle objects.         *

*********************************************************************************/

public class Exercise_13_06 {

/** Main method */

public static void main(String[] args) {

 // Create two instances of ComparableCircle objects

 ComparableCircle comparableCircle1 = new ComparableCircle(12.5);

 ComparableCircle comparableCircle2 = new ComparableCircle(18.3);

 // Display comparableCircles

 System.out.println("\nComparableCircle1:");

 System.out.println(comparableCircle1);

 System.out.println("\nComparableCircle2:");

 System.out.println(comparableCircle2);

 // Find and display the larger of the two ComparableCircle objects

 System.out.println((comparableCircle1.compareTo(comparableCircle2) == 1  

  ? "\nComparableCircle1 " : "\nComparableCircle2 ") +  

  "is the larger of the two Circles");

}

}

3 0
2 years ago
Other questions:
  • The fast food restaurant Chipotle pulled its app from Apple's app store when customer demand caused the firm's servers to crash.
    14·1 answer
  • You install an M.2 SSD card in an M.2 slot on a motherboard. When you boot up your system, you discover the DVD drive no longer
    15·1 answer
  • A forensics workstation consisting of a laptop computer with almost as many bays and peripherals as a stationary workstation is
    10·1 answer
  • Does anybody know if that apple watch is actually worth what it costs?
    9·2 answers
  • What lets you do many things, like write book reports and stories?
    15·1 answer
  • _____ involves storing data and running applications outside the company’s firewall. answer grid computing parallel computing cl
    11·1 answer
  • What are the two basic classes of active directory objects?
    14·1 answer
  • Which option represents the location of the Goal Seek function?
    8·2 answers
  • Ou have recently issued new mobile phones to the sales team in your company. Each phone has the ability to store and transmit en
    14·1 answer
  • How do you do 1.17.5, invert colors, on codehs?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!