MIPS Assembly: Below is the code and attached is the syntax error it has. Please fix the syntax error and print the output. Attached is image of what the output must be.   Data.asm   .data arr: .word 7, 9, 4, 3, 8, 1, 6, 2, 5 n:  .word 9 n .text .globl main main: la  $t0, arr   # Load address of arr la  $t1, n    # Load address of n lw  $t2, 0($t1)  # Load n into $t2 jal  radixSort   # Call radixSort la  $a0, arr   # Load address of arr lw  $a1, 0($t1)  # Load n into $a1 jal  printData   # Call printData li  $v0, 10   # Exit the program syscall radixSort: la  $a0, arr   # Load address of arr lw  $a1, 0($t1)  # Load n into $a1 jal  getMax    # Call getMax move $t3, $v0   # Move the max to $t3 move $t4, $zero   # Move 0 to $t4 loop: ble  $t3, $zero, Exit # Check if m/exp <= 0 mul  $t5, $t4, 10  # Multiply exp by 10 jal  countSort   # Call countSort addi $t4, $t4, 1  # Increment exp div  $t3, $t3, 10  # Divide m by 10 j  loop    # Loop back Exit: jr  $ra     # Return getMax: move $t6, $zero   # Move 0 to $t6 loop2: bge  $t6, $a1, Exit2  # Check if i >= n sll  $t7, $t6, 2  # Multiply i by 4 add  $t7, $t0, $t7  # Add the address of arr to $t7 lw  $t8, 0($t7)  # Load arr[i] into $t8 ble  $t8, $v0, Skip  # Check if arr[i] <= mx move $v0, $t8   # Move arr[i] to mx Skip: addi $t6, $t6, 1  # Increment i j  loop2    # Loop back Exit2: jr  $ra     # Return countSort: la  $a2, output   # Load address of output li  $t9, 0    # Move 0 to $t9 loop3: bge  $t9, $a1, Exit3  # Check if i >= n sll  $t10, $t9, 2  # Multiply i by 4 add  $t10, $t0, $t10 # Add the address of arr to $t10 lw  $t11, 0($t10)  # Load arr[i] into $t11 div  $t12, $t11, $a3 # Divide arr[i] by exp rem  $t13, $t12, 10  # Compute arr[i] % 10 sll  $t14, $t13, 2  # Multiply arr[i] % 10 by 4 add  $t14, $t14, count # Add the address of count to $t14 lw  $t15, 0($t14)  # Load count[arr[i] % 10] into $t15 addi $t16, $t15, 1  # Increment count[arr[i] % 10] sw  $t16, 0($t14)  # Store count[arr[i] % 10] addi $t9, $t9, 1  # Increment i j  loop3    # Loop back Exit3: li  $t9, 0    # Move 0 to $t9 loop4: bge  $t9, $a1, Exit4  # Check if i >= n sll  $t17, $t9, 2  # Multiply i by 4 add  $t17, $t17, count # Add the address of count to $t17 lw  $t18, 0($t17)  # Load count[i] into $t18 bgtz $t9, Skip2   # Check if i > 0 move $t19, $zero   # Move 0 to $t19 j  Skip3    # Skip Skip2: sll  $t20, $t9, 2  # Multiply i by 4 sub  $t20, $t20, 4  # Subtract 4 from $t20 add  $t20, $t20, count # Add the address of count to $t20 lw  $t19, 0($t20)  # Load count[i-1] into $t19 Skip3: sub  $t21, $t18, $t19 # Subtract count[i-1] from count[i] subi $t21, $t21, 1  # Decrement count[i] sll  $t22, $t9, 2  # Multiply i by 4 add  $t22, $t22, output # Add the address of output to $t22 sw  $t21, 0($t22)  # Store output[count[i]-1] sll  $t23, $t9, 2  # Multiply i by 4 add  $t23, $t0, $t23  # Add the address of arr to $t23 lw  $t24, 0($t23)  # Load arr[i] into $t24 div  $t25, $t24, $a3 # Divide arr[i] by exp rem  $t26, $t25, 10  # Compute arr[i] % 10 sll  $t27, $t26, 2  # Multiply arr[i] % 10 by 4 add  $t27, $t27, count # Add the address of count to $t27 sw  $t21, 0($t27)  # Store count[arr[i] % 10] addi $t9, $t9, 1  # Increment i j  loop4    # Loop back Exit4: li  $t9, 0    # Move 0 to $t9 loop5: bge  $t9, $a1, Exit5  # Check if i >= n sll  $t28, $t9, 2  # Multiply i by 4 sub  $t28, $a1, $t9  # Subtract n from i subi $t28, $t28, 1  # Decrement i sll  $t29, $t28, 2  # Multiply i by 4 add  $t29, $t29, output # Add the address of output to $t29 lw  $t30, 0($t29)  # Load output[i] into $t30 sll  $t31, $t9, 2  # Multiply i by 4 add  $t31, $t0, $t31  # Add the address of arr to $t31 sw  $t30, 0($t31)  # Store arr[i] addi $t9, $t9, 1  # Increment i j  loop5    # Loop back Exit5: jr  $ra     # Return printData: li  $t9, 0    # Move 0 to $t9 loop6: bge  $t9, $a1, Exit6  # Check if i >= n sll  $t32, $t9, 2  # Multiply i by 4 add  $t32, $t0, $t32  # Add the address of arr to $t32 lw  $a0, 0($t32)  # Load arr[i] into $a0 li  $v0, 1    # Print an integer syscall li  $v0, 11   # Print a new line li  $a0, 10   # Load 10 into $a0 syscall addi $t9, $t9, 1  # Increment i j  loop6    # Loop back Exit6: jr  $ra     # Return

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Topic Video
Question

MIPS Assembly: Below is the code and attached is the syntax error it has. Please fix the syntax error and print the output. Attached is image of what the output must be.

 

Data.asm

 

.data
arr: .word 7, 9, 4, 3, 8, 1, 6, 2, 5
n:  .word 9 n

.text
.globl main
main:
la  $t0, arr   # Load address of arr
la  $t1, n    # Load address of n
lw  $t2, 0($t1)  # Load n into $t2

jal  radixSort   # Call radixSort

la  $a0, arr   # Load address of arr
lw  $a1, 0($t1)  # Load n into $a1
jal  printData   # Call printData

li  $v0, 10   # Exit the program
syscall
radixSort:
la  $a0, arr   # Load address of arr
lw  $a1, 0($t1)  # Load n into $a1

jal  getMax    # Call getMax

move $t3, $v0   # Move the max to $t3
move $t4, $zero   # Move 0 to $t4

loop:
ble  $t3, $zero, Exit # Check if m/exp <= 0

mul  $t5, $t4, 10  # Multiply exp by 10
jal  countSort   # Call countSort

addi $t4, $t4, 1  # Increment exp
div  $t3, $t3, 10  # Divide m by 10
j  loop    # Loop back

Exit:
jr  $ra     # Return
getMax:
move $t6, $zero   # Move 0 to $t6

loop2:
bge  $t6, $a1, Exit2  # Check if i >= n

sll  $t7, $t6, 2  # Multiply i by 4
add  $t7, $t0, $t7  # Add the address of arr to $t7
lw  $t8, 0($t7)  # Load arr[i] into $t8

ble  $t8, $v0, Skip  # Check if arr[i] <= mx
move $v0, $t8   # Move arr[i] to mx

Skip:
addi $t6, $t6, 1  # Increment i
j  loop2    # Loop back

Exit2:
jr  $ra     # Return
countSort:
la  $a2, output   # Load address of output
li  $t9, 0    # Move 0 to $t9

loop3:
bge  $t9, $a1, Exit3  # Check if i >= n

sll  $t10, $t9, 2  # Multiply i by 4
add  $t10, $t0, $t10 # Add the address of arr to $t10
lw  $t11, 0($t10)  # Load arr[i] into $t11
div  $t12, $t11, $a3 # Divide arr[i] by exp
rem  $t13, $t12, 10  # Compute arr[i] % 10

sll  $t14, $t13, 2  # Multiply arr[i] % 10 by 4
add  $t14, $t14, count # Add the address of count to $t14
lw  $t15, 0($t14)  # Load count[arr[i] % 10] into $t15
addi $t16, $t15, 1  # Increment count[arr[i] % 10]
sw  $t16, 0($t14)  # Store count[arr[i] % 10]

addi $t9, $t9, 1  # Increment i
j  loop3    # Loop back

Exit3:
li  $t9, 0    # Move 0 to $t9

loop4:
bge  $t9, $a1, Exit4  # Check if i >= n

sll  $t17, $t9, 2  # Multiply i by 4
add  $t17, $t17, count # Add the address of count to $t17
lw  $t18, 0($t17)  # Load count[i] into $t18

bgtz $t9, Skip2   # Check if i > 0
move $t19, $zero   # Move 0 to $t19
j  Skip3    # Skip

Skip2:
sll  $t20, $t9, 2  # Multiply i by 4
sub  $t20, $t20, 4  # Subtract 4 from $t20
add  $t20, $t20, count # Add the address of count to $t20
lw  $t19, 0($t20)  # Load count[i-1] into $t19

Skip3:
sub  $t21, $t18, $t19 # Subtract count[i-1] from count[i]
subi $t21, $t21, 1  # Decrement count[i]

sll  $t22, $t9, 2  # Multiply i by 4
add  $t22, $t22, output # Add the address of output to $t22
sw  $t21, 0($t22)  # Store output[count[i]-1]

sll  $t23, $t9, 2  # Multiply i by 4
add  $t23, $t0, $t23  # Add the address of arr to $t23
lw  $t24, 0($t23)  # Load arr[i] into $t24
div  $t25, $t24, $a3 # Divide arr[i] by exp
rem  $t26, $t25, 10  # Compute arr[i] % 10

sll  $t27, $t26, 2  # Multiply arr[i] % 10 by 4
add  $t27, $t27, count # Add the address of count to $t27
sw  $t21, 0($t27)  # Store count[arr[i] % 10]

addi $t9, $t9, 1  # Increment i
j  loop4    # Loop back

Exit4:
li  $t9, 0    # Move 0 to $t9

loop5:
bge  $t9, $a1, Exit5  # Check if i >= n

sll  $t28, $t9, 2  # Multiply i by 4
sub  $t28, $a1, $t9  # Subtract n from i
subi $t28, $t28, 1  # Decrement i
sll  $t29, $t28, 2  # Multiply i by 4
add  $t29, $t29, output # Add the address of output to $t29
lw  $t30, 0($t29)  # Load output[i] into $t30

sll  $t31, $t9, 2  # Multiply i by 4
add  $t31, $t0, $t31  # Add the address of arr to $t31
sw  $t30, 0($t31)  # Store arr[i]

addi $t9, $t9, 1  # Increment i
j  loop5    # Loop back

Exit5:
jr  $ra     # Return
printData:
li  $t9, 0    # Move 0 to $t9

loop6:
bge  $t9, $a1, Exit6  # Check if i >= n

sll  $t32, $t9, 2  # Multiply i by 4
add  $t32, $t0, $t32  # Add the address of arr to $t32
lw  $a0, 0($t32)  # Load arr[i] into $a0

li  $v0, 1    # Print an integer
syscall

li  $v0, 11   # Print a new line
li  $a0, 10   # Load 10 into $a0
syscall

addi $t9, $t9, 1  # Increment i
j  loop6    # Loop back

Exit6:
jr  $ra     # Return

 

 

1
3
6
7
8
9
input
out put
... Program finished with exit code 0
Press ENTER to exit console.
Transcribed Image Text:1 3 6 7 8 9 input out put ... Program finished with exit code 0 Press ENTER to exit console.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education