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
guajiro [1.7K]
3 years ago
7

Write an Assembly program in MIPS that does the following:

Computers and Technology
1 answer:
hjlf3 years ago
6 0

Answer:

see explaination

Explanation:

#DATA SECTION

.data

#Decalre x

x: .word 0

#declare y

y: .word 0

#Declare variables

choice: .space 1

#Store the repeat choice

op: .asciiz "C"

#Prompt

prompt1: .asciiz "\nEnter 2 integers:\n"

#Declare string for menu

menu: .asciiz "\nMenu \n 1. Addition\n 2. Subtraction \n 3. Multiplication \n 4. Division \nEnter your choice:"

#Declare string for repeat

repeat: .asciiz "\nDo u want to continue (C) or quit(Q):"

#Declare string for result

result: .asciiz "Result="

#Code section

.text

#main

main:

#label

continue:

#Load code to print string

li $v0, 4

#Load the base address of prompt1

la $a0, prompt1

#Print string

syscall

#Load code to read integer

li $v0, 5

#Read integer

syscall

#Store integer in x

sw $v0, x

#load code to read integer

li $v0, 5

#read integer

syscall

#Store in y

sw $v0, y

#Load code to print string menu

li $v0, 4

#Load address of menu

la $a0, menu

#Print string

syscall

#Load code to read integer

li $v0, 5

#Read integer

syscall

#Store the operation choice in $a1

move $a1, $v0

#Check user wishes to add

beq $a1, 1, addition

#Check user wishes to do subtraction

beq $a1, 2, subtraction

#Check user wishes to do multiplication

beq $a1, 3, multiplication

#Check user wishes to do division

beq $a1, 4, division

#Ask user for repetition

GetChoice:

#Load code to print string "repeat"

li $v0, 4

#Load address of repeat

la $a0, repeat

#Print string

syscall

#Load code to read character

li $v0, 12

#Read character

syscall

#Store character in choice

sb $v0, choice

#Load user choice

lb $t2, choice

#Load repeat option

lb $t3, op

#Check both

#If user wishes to continue, then go to continue

beq $t2, $t3, continue

#Else stop the program

j programEnd

#For addition

addition:

#load x

lw $t4, x

#load y

lw $t5, y

#Add

add $t6, $t4, $t5

#Load code to print result

li $v0, 4

#load result address

la $a0, result

#Print result

syscall

#load code to print integer

li $v0, 1

#load the value

move $a0, $t6

#print the integer

syscall

#Jump to get choice

j GetChoice

#For subtraction

subtraction:

#load x

lw $t4, x

#load y

lw $t5, y

#Add

sub $t6, $t4, $t5

#Load code to print result

li $v0, 4

#load result address

la $a0, result

#Print result

syscall

#load code to print integer

li $v0, 1

#load the value

move $a0, $t6

#print the integer

syscall

#Jump to get choice

j GetChoice

#For multiplication

multiplication:

#load x

lw $t4, x

#load y

lw $t5, y

#Add

mul $t6, $t4, $t5

#Load code to print result

li $v0, 4

#load result address

la $a0, result

#Print result

syscall

#load code to print integer

li $v0, 1

#load the value

move $a0, $t6

#print the integer

syscall

#Jump to get choice

j GetChoice

#Division

division:

#load x

lw $t4, x

#load y

lw $t5, y

#Add

div $t6, $t4, $t5

#Load code to print result

li $v0, 4

#load result address

la $a0, result

#Print result

syscall

#load code to print integer

li $v0, 1

#load the value

move $a0, $t6

#print the integer

syscall

#Jump to get choice

j GetChoice

#end

programEnd:

#loa dcode to stop the program

li $v0, 10

syscall

You might be interested in
Comments should be written in what type of language
jeyben [28]
Comment should always be answered in the prospective language the question is asked.
8 0
4 years ago
1) The critical path of a network is the A) shortest time path through the network. B) path with the fewest activities. C) path
german

Answer:

D

Explanation:

source

https://hbr.org/1963/09/the-abcs-of-the-critical-path-method

7 0
3 years ago
ANSWER QUICKLY PLEASE
DochEvi [55]

Explanation:

I don't know what is the question.

? should have the value of 4

binary digit 10000011 is equal to 128 plus 2 plus 1 = 131 in decimal

3 0
3 years ago
Data driven processes: Select one: a. are heavily based on intuition b. rely heavily on the experience of the process owners c.
krek1111 [17]

Answer:

c. are based on statistical data, measurement and metrics

Explanation:

Data driven process are process that are not based on intuition but rather are based on data. This data serves as evidence to back a decision that is to be taken. It therefore means that, whatever decision that will be taken, such a decision will be based on the data presented.

6 0
3 years ago
How is cropping different from scaling?​
Keith_Richards [23]

Answer:

Scaling changes the size of the whole image by resampling it(duplicating the pixels). in cropping you only get a part of the original image/ remove the outer area of it .

Explanation:

8 0
3 years ago
Other questions:
  • The __________ determines whether coolant should be pumped back into the engine directly or cooled first.
    15·1 answer
  • Which type of server runs Active Directory?
    12·1 answer
  • You are seeking a way to store computer files so you have backup copies anywhere you go.? Which one of the secondary storage typ
    11·1 answer
  • 1. The Law of Superposition – the age of an object may be determined by the depth at which it is found, the deeper the object is
    14·1 answer
  • If the user does NOT click the button what color will "topButton" be when this program finishes running?
    6·1 answer
  • Why is it important to put the most specific case first? What types of errors does it help avoid?
    11·1 answer
  • Disadvantages of computer. ​
    9·1 answer
  • Answer the following questions which are based on the study "Patients' Engagement with Sweet Talk." Submit your answers.
    8·1 answer
  • What is coupling in computer science <br><br>​
    13·2 answers
  • bailey reads wikis at the beginning of his research project to get his bearings on the topic. he switches to peer-reviewed journ
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!