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
Define the method object inc_num_kids() for PersonInfo. inc_num_kids increments the member data num_kids.Sample output for the g
topjm [15]

Answer:

class PersonInfo:

   def __init__(self):

       self.num_kids = 0

   def inc_num_kids(self):

       self.num_kids += 1

person1 = PersonInfo()

print('Kids:', person1.num_kids)

person1.inc_num_kids()

print('New baby, kids now:', person1.num_kids)

Explanation:

Line 1 of the code, we define the class PersonInfo. Line 3 of the code is the function that will increment the member data num_kids.

4 0
4 years ago
Etapas del desarrollo​
cestrela7 [59]

Answer:

Las etapas del desarrollo humano

Etapa prenatal. Comprende desde la concepción hasta el parto. ...

Etapa de la niñez. Es la comprendida entre el nacimiento y los tres años. ...

Primera infancia. Desde los 3 a los 6 años. ...

Infancia intermedia. ...

Adolescencia. ...

Etapa adulta temprana.

Edad adulta intermedia.

Edad adulta tardía.

Explanation:

5 0
3 years ago
A computer program is tested by 5 independent tests. If there is an error, these tests will discover it with probabilities 0.1,
Svetllana [295]

Answer:

0.8488

Explanation:

Let E =error found by test 1

Let F=error found by test 2

Let G=error found by test 3

Let H=error found by test 4

Let I= error found by test 5

Given P(E)=0.1, P(F)=0.2, P(G)=0.3, P (H)= 0.4, P (I)=0.5

therefore P(notE)=0.9, P(notF)=0.8, P(notG)=0.7, P(not H)=0.6, P (notI)=0.5

Tests are independent P(not E & not F &not G & not H & not I=P(notE)*P(notF)*P(notG)*P (notH)*P (not I) =0.9*0.8*0.7*0.6*0.5 =0.1512

P(found by at least one test)= 1- P(not found by any test)=1-P(not E& not F & not G & not H & not I ) = 1-0.1512 = 0.8488

5 0
3 years ago
Rickie gets a message from the school’s tech support department. Their computer is supposed to be running the latest system soft
raketka [301]

Answer:

the operating system or web browser

6 0
3 years ago
Read 2 more answers
ASAP help me I dont have enough time
umka21 [38]

Answer:third stage of parent-infant attachment

Explanation:

7 0
2 years ago
Other questions:
  • What is the output of the following program? #include using namespace std; class TestClass { private: int val; void showVal() {
    5·1 answer
  • A group of students want to create an educational online game for computer laboratory in their school which type of network will
    6·1 answer
  • Which is an internet service?<br><br> Antivirus<br> Chat<br> Firewall<br> Router
    8·2 answers
  • The use of themes in WordPress is a good illustration of what major concept?
    6·1 answer
  • Paul has been working long hours. He is tired and distracted by family issues,
    10·1 answer
  • Which programming element is used by a game program to track and display score information
    12·2 answers
  • Which option should you select to ignore all tracked changes in a document? To ignore all tracked changes in a document, you sho
    14·1 answer
  • Hi um... i just wanna say hi :P
    6·2 answers
  • Acciones de un lápiz
    7·1 answer
  • dash is a set of communication standard using for transferring file information between computers in a network​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!