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
Nady [450]
3 years ago
10

For the first option your program should then ask the user for which row and column in the array to replace, and what value will

it be replaced with. For the second option your program should run through all values held in the 2D array and calculate their summation. For the third option your program should print out the contents of the 2D array one row at a time. When given the fourth option your program should simply exit.

Engineering
1 answer:
Andrew [12]3 years ago
3 0

Answer:

#Data section

.data

#Set align

.align 2

#Declare row 1

M1: .word 1, 2, 3

#Declare row 2 elements

M2: .word 4, 5, 6

#Declare row 3 elements

M3: .word 7, 8, 9

#Declare row 4 elements

M4: .word 10, 11, 12

#Declare row 5 elements

M5: .word 13, 14, 15

#Create 5x3 array

M: .word M1, M2, M3, M4, M5

#Set number of rows

nRows: .word 5

#Set number of columns

nCols: .word 3

#Declare string menu

menu: .asciiz "\n The following are the choices:\n"

#Declare string for option 1

op1: .asciiz "1. Replace a value:\n"

#Define string for option 2

op2: .asciiz "2. Calculate the sum of all values\n"

#Define string for option 3

op3: .asciiz "3. Print out the 2D array \n"

#Define string for option 4

op4: .asciiz "4. Exit\n"

#Define string for prompt

urOpt: .asciiz "Enter your option:"

#Define string for row

prompt1: .asciiz "Enter row (1-5):"

#Define string for column input

prompt2: .asciiz "Enter column (1-3):"

#Define string to get the replace value

getVal: .asciiz "Enter the new value:"

#Define strinct to display sum

sumStr: .asciiz "\nThe sum is :"

#Define string

dispStr: .asciiz "The 2D array is:\n"

#Define string to print new line

newLine: .asciiz "\n"

#Define string to put comma

comma: .asciiz ","

#text section

.text

#Main

main:

#Block prints the 2D array

#label

print2DArray:

#Load integer to print string in $v0

li $v0, 4

#Load the address of string to display

la $a0, dispStr

#Display the string

syscall

#Load the base address of the row 1

la $s0, M1

#Load the nRows

lw $t0, nRows

#Initialize the counter for outer loop

li $t7, 0

#Outer loop begins

outLoop1:

#Check condition

beq $t7, $t0, displayMenu

#Load the integer to print string

li $v0, 4

#Load the base address of newLine

la $a0, newLine

#Display newLine

syscall

#Initialize counter for inner loop

li $t2, 0

#Set the limit

lw $t3, nCols

#Decrement value

addi $t3, $t3, -1

#inner loop starts

inLoop1:

#Check condition

beq $t2, $t3, exitInLoop1

#Load the integer to print number

li $v0, 1

#Load the value

lw $a0, ($s0)

#Display the integer

syscall

#Load the integer to print string

li $v0, 4

#Load the base address of the string comma to display

la $a0, comma

#Display comma

syscall

#Increment inner loop counter value

addi $t2, $t2, 1

#Move to next element

addi $s0, $s0, 4

#jump to inner loop

j inLoop1

#Exit from inner loop

exitInLoop1:

#Load integer to print last column value

li $v0, 1

#Load the load column value

lw $a0, ($s0)

#Print value

syscall

#Move to next element

addi $s0, $s0, 4

#Increment outer loop counter

addi $t7, $t7, 1

#Jump to start of the outer loop

j outLoop1

#Prints the menus to the user

displayMenu:

#Load integer value to print string

li $v0, 4

#Load the address of the string "menu"

la $a0, menu

#Print the string

syscall

#Load the integer value to print string

li $v0, 4

#Load the address

la $a0, op1

#Print the string

syscall

#Load the integer value to print string

li $v0, 4

#Load the address

la $a0, op2

#Print string

syscall

#Load integer value to print string

li $v0, 4

#Load address of op3

la $a0, op3

#Print string

syscall

#Load integer value to print string

li $v0, 4

#Load the address

la $a0, op4

#Print string

syscall

#Load integer value to print sting

li $v0, 4

#Load address

la $a0, urOpt

#Print string

syscall

#Load the integer to read int value

li $v0, 5

#Read value

syscall

#Move value

move $t0, $v0

#Initialize values

li $t1, 1

li $t2, 2

li $t3, 3

li $t4, 4

#Check user wishes option 1

beq $t0, $t1, replaceBlock

#Check user wishes option 2

beq $t0, $t2, sumBlock

#Check user wishes option 3

beq $t0, $t3, print2DArray

#Check user wishes to exit

beq $t0, $t4, EndProgram

#Jump to start of the menu

j displayMenu

#Block to replace a value in the 2d array

replaceBlock:

#Load integer

li $v0, 4

#load address

la $a0, prompt1

#Print string

syscall

#Read row value

li $v0, 5

syscall

#Store the row value in $t6

move $t6, $v0

#Get the index

addi $t6, $t6, -1

#Load integer

li $v0, 4

#Load address

la $a0, prompt2

#Print string

syscall

#Read column value

li $v0, 5

syscall

#Store the column value in $t7

move $t7, $v0

#Get the index for the column

addi $t7, $t7, -1

#Load integer

li $v0, 4

#Load address

la $a0, getVal

#Print string

syscall

#Read the new value

li $v0, 5

syscall

#Store the new value in $t5

move $t5, $v0

#Load the base address of M

la $s0, M

#Get M[i]

#two times left shift

sll $t1, $t6, 2

#address of pointer M[i]

add $t1, $t1, $s0

#Get address of M[i]

lw $t3, ($t1)

#Get M[i][j]

#two times left shift

sll $t4, $t7, 2

#Get address of M[i][j]

add $t4, $t3, $t4

Explanation:

See continuation of the code attached

also, See output attached

You might be interested in
Bằng lý luận và thực tiễn, bạn hãy trình bày ý kiến của mình về quan điểm sau đây: "Quá trình dạy học là quá trình truyền thụ tr
mrs_skeptik [129]

Answer:

can you please ask in English I can't understand this language

7 0
3 years ago
Given asphalt content test data:
VMariaS [17]

Answer:

hello your question is incomplete attached below is the complete question

A) overall mean = 5.535,  standard deviation ≈ 0.3239

B ) upper limit = 5.85, lower limit = 5.0

C) Not all the samples meet the contract specifications

D) fluctuation ( unstable Asphalt content )

Explanation:

B) The daily average asphalt content has to obtained in order to determine the upper and lower control limits using an average asphalt content of 5.5% +/- 0.5% everyday

The upper limit : 14 may = ( 5.8 + 5.1 ) / 2 = 5.85

The lower limit : 16 may = ( 5.2 + 4.8 ) / 2 = 5.0

attached below is the required plot

C ) Not all the samples meet the contract specifications and the samples that do not meet up are samples from :

15 may and 16 may . this is because their Asphalt contents are 6.2 and 4.8 respectively and sample number 18 and 20

D ) what can be observed is that the ASPHALT content fluctuates between the dates while the contract specification is fixed

5 0
4 years ago
When does the vc-turbo engine use lower compression ratios?.
Veronika [31]

Answer:

Explanation:

The VC-T engine (for "variable compression, turbocharged") can adjust its compression ratio between 8:1 and 14:1 on the fly, offering high-compression efficiency under light loads and the low compression needed for turbocharged power under hard acceleration.

7 0
2 years ago
When Ontario
Marat540 [252]

Answer:

Explanation:

This will be possible when setting them up in summer with a certain quantity of sag, they have already know that the cables won't be able to sag any further because of the heat. During winter, when the cables contract because of the cold weather, the sag will therefore be reduced, but much tension will not be put on the cables.

4 0
3 years ago
LINKS GET BODIED ON SITE! RAWR
bulgar [2K]

Answer:

False

Explanation:

MRK ME BRAINLIEST PLZZZZZZZZZZZZZZZZZZ

7 0
4 years ago
Other questions:
  • 1. A copper block of volume 1 L is heat treated at 500ºC and now cooled in a 200-L oil bath initially at 20◦C. Assuming no heat
    10·1 answer
  • A DC generator turns at 2000 rpm and has an output of 200 V. The armature constant is 0.5 V-min/Wb, and the field constant of th
    6·2 answers
  • A belt drive was designed to transmit the power of P=7.5 kW with the velocity v=10m/s. The tensile load of the tight side is twi
    14·1 answer
  • Three consequences of unbalanced wheels on a motor vehicle​
    11·1 answer
  • What type of plans have to do with earth, soil, excavation, and location<br> of a house on a lot?
    12·1 answer
  • Can you use isentropic efficiency for a non-adiabatic compressor?
    12·1 answer
  • 48/64 reduced to its lowest term
    5·2 answers
  • 28. What is the value of a resistor in a series circuit if you measure 0.5 amps flowing through it and 15 volts
    10·1 answer
  • In the construction of a timber-framed house, select and justify three timber based
    13·1 answer
  • The art of manipulating, influencing, or deceiving you into taking some action that isn’t in your best interest or in the best i
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!