SlideShare a Scribd company logo
Finish the program below that does several bit-wise manipulations of C integers.
Cut and paste the following:
Finish the Program!
You may only use the integer constants given at the beginning. (You may use whatever integers
you wish in string constants as long as they are for printf()'s. For example the format string
"0x%08X" is useful for printing hexadecimal integers.)
You may only use the following integer operators:
+
-
++
--
<<
>>
~
|
&
<
>
=
!=
==
Sample output (32 bit):
Sample output (64 bit):
Solution
mm:
la $a3, array_A # base address for array_A loaded into $a3
la $a1, array_B # base address for array_B loaded into $a1
la $a2, array_C # base address for array_C loaded into $a2
li $t1, four # $t1 = four (row-size and loop end)
li $s0, zero # i = 0; initialize first for loop
loop1:
li $s1, zero # j = 0; restart 2d for loop
loop2:
li $s2, zero # k = 0; restart third for loop
sll $t2, $s0, two # $t2 = i * four (size of row of c)
addu $t2, $t2, $s1 # $t2 = i * size(row) + j
sll $t2, $t2, two # $t2 = computer memory unit offset of [i][j]
addu $t2, $a2, $t2 # $t2 = computer memory unit offset of [i][j]
lw $t4, 0($t2) # $t4 = two bytes of c[i][j]
loop3:
sll $t0, $s2, two # $t0 = k * four (size of row of b)
addu $t0, $t0, $s1 # $t0 = k * size(row) + j
sll $t0, $t0, two # $t0 = computer memory unit offset off [k][j]
addu $t0, $a1, $t0 # $t0 = computer memory unit address of b[k][j]
lw $t5, 0($t0) # $t5 = two bytes of b[k][j]
sll $t0, $s0, two # $t0 = i * four (size of row of a)
addu $t0, $t0, $s2 # $t0 = i * size(row) + k
sll $t0, $t0, two # $t0 = computer memory unit offset of [i][k]
addu $t0, $a3, $t0 # $t0 = computer memory unit address of a[i][k]
lw $t6, 0($t0) # $t6 = two bytes of a[i][k]
mul $t5, $t6, $t5 # $t5 = a[i][k] * b[k][j]
add $t4, $t4, $t5 # $t4 = c[i][j] + a[i][k] * b[k][j]
addiu $s2, $s2, one # $k = k + one
bne $s2, $t1, loop3 #if (k != 4) attend loop3
sw $t4, 0($a2) # c[i][j] = $t4
#----------TEST-------------
li $v0, 1
lw $a0, ($a2)
syscall
li $v0, 4
la $a0, new_row
syscall
#----------TEST-------------
addiu $s1, $s1, one # $j = j + one
addi $a2, $a2, 4
bne $s1, $t1, loop2 # if (j != 4) attend loop2
addiu $s0, $s0, one # $i = i + one
bne $s0, $t1, loop1 # if (i != 32) attend L1
Exit:
li $v0, 10 #exits
syscall
.data
array_A: .word 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
array_B: .word 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
array_C: .word 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
output_row_string_C: .asciiz "Matrix C Output Row "
colon_string: .asciiz ":
mm:
la $a3, array_A # base address for array_A loaded into $a3
la $a1, array_B # base address for array_B loaded into $a1
la $a2, array_C # base address for array_C loaded into $a2
li $t1, four # $t1 = four (row-size and loop end)
li $s0, zero # i = 0; initialize first for loop
loop1:
li $s1, zero # j = 0; restart 2d for loop
loop2:
li $s2, zero # k = 0; restart third for loop
sll $t2, $s0, two # $t2 = i * four (size of row of c)
addu $t2, $t2, $s1 # $t2 = i * size(row) + j
sll $t2, $t2, two # $t2 = computer memory unit offset of [i][j]
addu $t2, $a2, $t2 # $t2 = computer memory unit offset of [i][j]
lw $t4, 0($t2) # $t4 = two bytes of c[i][j]
loop3:
sll $t0, $s2, two # $t0 = k * four (size of row of b)
addu $t0, $t0, $s1 # $t0 = k * size(row) + j
sll $t0, $t0, two # $t0 = computer memory unit offset off [k][j]
addu $t0, $a1, $t0 # $t0 = computer memory unit address of b[k][j]
lw $t5, 0($t0) # $t5 = two bytes of b[k][j]
sll $t0, $s0, two # $t0 = i * four (size of row of a)
addu $t0, $t0, $s2 # $t0 = i * size(row) + k
sll $t0, $t0, two # $t0 = computer memory unit offset of [i][k]
addu $t0, $a3, $t0 # $t0 = computer memory unit address of a[i][k]
lw $t6, 0($t0) # $t6 = two bytes of a[i][k]
mul $t5, $t6, $t5 # $t5 = a[i][k] * b[k][j]
add $t4, $t4, $t5 # $t4 = c[i][j] + a[i][k] * b[k][j]
addiu $s2, $s2, one # $k = k + one
bne $s2, $t1, loop3 #if (k != 4) attend loop3
sw $t4, 0($a2) # c[i][j] = $t4
#----------TEST-------------
li $v0, 1
lw $a0, ($a2)
syscall
li $v0, 4
la $a0, new_row
syscall
#----------TEST-------------
addiu $s1, $s1, one # $j = j + one
addi $a2, $a2, 4
bne $s1, $t1, loop2 # if (j != 4) attend loop2
addiu $s0, $s0, one # $i = i + one
bne $s0, $t1, loop1 # if (i != 32) attend L1
Exit:
li $v0, 10 #exits
syscall
.data
array_A: .word 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
array_B: .word 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
array_C: .word 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
output_row_string_C: .asciiz "Matrix C Output Row "
colon_string: .asciiz ":mm:
la $a3, array_A # base address for array_A loaded into $a3
la $a1, array_B # base address for array_B loaded into $a1
la $a2, array_C # base address for array_C loaded into $a2
li $t1, four # $t1 = four (row-size and loop end)
li $s0, zero # i = 0; initialize first for loop
loop1:
li $s1, zero # j = 0; restart 2d for loop
loop2:
li $s2, zero # k = 0; restart third for loop
sll $t2, $s0, two # $t2 = i * four (size of row of c)
addu $t2, $t2, $s1 # $t2 = i * size(row) + j
sll $t2, $t2, two # $t2 = computer memory unit offset of [i][j]
addu $t2, $a2, $t2 # $t2 = computer memory unit offset of [i][j]
lw $t4, 0($t2) # $t4 = two bytes of c[i][j]
loop3:
sll $t0, $s2, two # $t0 = k * four (size of row of b)
addu $t0, $t0, $s1 # $t0 = k * size(row) + j
sll $t0, $t0, two # $t0 = computer memory unit offset off [k][j]
addu $t0, $a1, $t0 # $t0 = computer memory unit address of b[k][j]
lw $t5, 0($t0) # $t5 = two bytes of b[k][j]
sll $t0, $s0, two # $t0 = i * four (size of row of a)
addu $t0, $t0, $s2 # $t0 = i * size(row) + k
sll $t0, $t0, two # $t0 = computer memory unit offset of [i][k]
addu $t0, $a3, $t0 # $t0 = computer memory unit address of a[i][k]
lw $t6, 0($t0) # $t6 = two bytes of a[i][k]
mul $t5, $t6, $t5 # $t5 = a[i][k] * b[k][j]
add $t4, $t4, $t5 # $t4 = c[i][j] + a[i][k] * b[k][j]
addiu $s2, $s2, one # $k = k + one
bne $s2, $t1, loop3 #if (k != 4) attend loop3
sw $t4, 0($a2) # c[i][j] = $t4
#----------TEST-------------
li $v0, 1
lw $a0, ($a2)
syscall
li $v0, 4
la $a0, new_row
syscall
#----------TEST-------------
addiu $s1, $s1, one # $j = j + one
addi $a2, $a2, 4
bne $s1, $t1, loop2 # if (j != 4) attend loop2
addiu $s0, $s0, one # $i = i + one
bne $s0, $t1, loop1 # if (i != 32) attend L1
Exit:
li $v0, 10 #exits
syscall
.data
array_A: .word 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
array_B: .word 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
array_C: .word 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
output_row_string_C: .asciiz "Matrix C Output Row "
colon_string: .asciiz ":
mm:
la $a3, array_A # base address for array_A loaded into $a3
la $a1, array_B # base address for array_B loaded into $a1
la $a2, array_C # base address for array_C loaded into $a2
li $t1, four # $t1 = four (row-size and loop end)
li $s0, zero # i = 0; initialize first for loop
loop1:
li $s1, zero # j = 0; restart 2d for loop
loop2:
li $s2, zero # k = 0; restart third for loop
sll $t2, $s0, two # $t2 = i * four (size of row of c)
addu $t2, $t2, $s1 # $t2 = i * size(row) + j
sll $t2, $t2, two # $t2 = computer memory unit offset of [i][j]
addu $t2, $a2, $t2 # $t2 = computer memory unit offset of [i][j]
lw $t4, 0($t2) # $t4 = two bytes of c[i][j]
loop3:
sll $t0, $s2, two # $t0 = k * four (size of row of b)
addu $t0, $t0, $s1 # $t0 = k * size(row) + j
sll $t0, $t0, two # $t0 = computer memory unit offset off [k][j]
addu $t0, $a1, $t0 # $t0 = computer memory unit address of b[k][j]
lw $t5, 0($t0) # $t5 = two bytes of b[k][j]
sll $t0, $s0, two # $t0 = i * four (size of row of a)
addu $t0, $t0, $s2 # $t0 = i * size(row) + k
sll $t0, $t0, two # $t0 = computer memory unit offset of [i][k]
addu $t0, $a3, $t0 # $t0 = computer memory unit address of a[i][k]
lw $t6, 0($t0) # $t6 = two bytes of a[i][k]
mul $t5, $t6, $t5 # $t5 = a[i][k] * b[k][j]
add $t4, $t4, $t5 # $t4 = c[i][j] + a[i][k] * b[k][j]
addiu $s2, $s2, one # $k = k + one
bne $s2, $t1, loop3 #if (k != 4) attend loop3
sw $t4, 0($a2) # c[i][j] = $t4
#----------TEST-------------
li $v0, 1
lw $a0, ($a2)
syscall
li $v0, 4
la $a0, new_row
syscall
#----------TEST-------------
addiu $s1, $s1, one # $j = j + one
addi $a2, $a2, 4
bne $s1, $t1, loop2 # if (j != 4) attend loop2
addiu $s0, $s0, one # $i = i + one
bne $s0, $t1, loop1 # if (i != 32) attend L1
Exit:
li $v0, 10 #exits
syscall
.data
array_A: .word 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
array_B: .word 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
array_C: .word 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
output_row_string_C: .asciiz "Matrix C Output Row "
colon_string: .asciiz ":

More Related Content

Similar to Finish the program below that does several bit-wise manipulations of.pdf

Python cheatsheat.pdf
Python cheatsheat.pdfPython cheatsheat.pdf
Python cheatsheat.pdf
HimoZZZ
 
C program
C programC program
C program
Komal Singh
 
‏‏chap6 list tuples.pptx
‏‏chap6 list tuples.pptx‏‏chap6 list tuples.pptx
‏‏chap6 list tuples.pptx
RamiHarrathi1
 
Mips
MipsMips
Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語
ikdysfm
 
Implementing Software Machines in C and Go
Implementing Software Machines in C and GoImplementing Software Machines in C and Go
Implementing Software Machines in C and Go
Eleanor McHugh
 
MIPS Merge Sort
MIPS Merge SortMIPS Merge Sort
MIPS Merge Sort
Adam Tucker
 
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
rushabhshah600
 
11 1. multi-dimensional array eng
11 1. multi-dimensional array eng11 1. multi-dimensional array eng
11 1. multi-dimensional array eng
웅식 전
 
CDMA simulation code for wireless Network.docx
CDMA simulation code for wireless Network.docxCDMA simulation code for wireless Network.docx
CDMA simulation code for wireless Network.docx
MaryamAziz47
 
The Ring programming language version 1.8 book - Part 28 of 202
The Ring programming language version 1.8 book - Part 28 of 202The Ring programming language version 1.8 book - Part 28 of 202
The Ring programming language version 1.8 book - Part 28 of 202
Mahmoud Samir Fayed
 
unit-2-dsa.pptx
unit-2-dsa.pptxunit-2-dsa.pptx
unit-2-dsa.pptx
sayalishivarkar1
 
Imugi: Compiler made with Python
Imugi: Compiler made with PythonImugi: Compiler made with Python
Imugi: Compiler made with Python
Han Lee
 
Task4output.txt 2 5 9 13 15 10 1 0 3 7 11 14 1.docx
Task4output.txt 2  5  9 13 15 10  1  0  3  7 11 14 1.docxTask4output.txt 2  5  9 13 15 10  1  0  3  7 11 14 1.docx
Task4output.txt 2 5 9 13 15 10 1 0 3 7 11 14 1.docx
josies1
 
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...
AntareepMajumder
 
Encryption and Decryption using Tag Design
Encryption and Decryption using Tag Design Encryption and Decryption using Tag Design
Encryption and Decryption using Tag Design
Joe Jiang
 
C:\Fakepath\Chapter 2 Part2 B
C:\Fakepath\Chapter 2 Part2 BC:\Fakepath\Chapter 2 Part2 B
C:\Fakepath\Chapter 2 Part2 B
ececourse
 
{- Do not change the skeleton code! The point of this assign.pdf
{-      Do not change the skeleton code! The point of this      assign.pdf{-      Do not change the skeleton code! The point of this      assign.pdf
{- Do not change the skeleton code! The point of this assign.pdf
atul2867
 
2- Dimensional Arrays
2- Dimensional Arrays2- Dimensional Arrays
2- Dimensional Arrays
Education Front
 
An overview of Python 2.7
An overview of Python 2.7An overview of Python 2.7
An overview of Python 2.7
decoupled
 

Similar to Finish the program below that does several bit-wise manipulations of.pdf (20)

Python cheatsheat.pdf
Python cheatsheat.pdfPython cheatsheat.pdf
Python cheatsheat.pdf
 
C program
C programC program
C program
 
‏‏chap6 list tuples.pptx
‏‏chap6 list tuples.pptx‏‏chap6 list tuples.pptx
‏‏chap6 list tuples.pptx
 
Mips
MipsMips
Mips
 
Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語
 
Implementing Software Machines in C and Go
Implementing Software Machines in C and GoImplementing Software Machines in C and Go
Implementing Software Machines in C and Go
 
MIPS Merge Sort
MIPS Merge SortMIPS Merge Sort
MIPS Merge Sort
 
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
 
11 1. multi-dimensional array eng
11 1. multi-dimensional array eng11 1. multi-dimensional array eng
11 1. multi-dimensional array eng
 
CDMA simulation code for wireless Network.docx
CDMA simulation code for wireless Network.docxCDMA simulation code for wireless Network.docx
CDMA simulation code for wireless Network.docx
 
The Ring programming language version 1.8 book - Part 28 of 202
The Ring programming language version 1.8 book - Part 28 of 202The Ring programming language version 1.8 book - Part 28 of 202
The Ring programming language version 1.8 book - Part 28 of 202
 
unit-2-dsa.pptx
unit-2-dsa.pptxunit-2-dsa.pptx
unit-2-dsa.pptx
 
Imugi: Compiler made with Python
Imugi: Compiler made with PythonImugi: Compiler made with Python
Imugi: Compiler made with Python
 
Task4output.txt 2 5 9 13 15 10 1 0 3 7 11 14 1.docx
Task4output.txt 2  5  9 13 15 10  1  0  3  7 11 14 1.docxTask4output.txt 2  5  9 13 15 10  1  0  3  7 11 14 1.docx
Task4output.txt 2 5 9 13 15 10 1 0 3 7 11 14 1.docx
 
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_08-08-2022_C_...
 
Encryption and Decryption using Tag Design
Encryption and Decryption using Tag Design Encryption and Decryption using Tag Design
Encryption and Decryption using Tag Design
 
C:\Fakepath\Chapter 2 Part2 B
C:\Fakepath\Chapter 2 Part2 BC:\Fakepath\Chapter 2 Part2 B
C:\Fakepath\Chapter 2 Part2 B
 
{- Do not change the skeleton code! The point of this assign.pdf
{-      Do not change the skeleton code! The point of this      assign.pdf{-      Do not change the skeleton code! The point of this      assign.pdf
{- Do not change the skeleton code! The point of this assign.pdf
 
2- Dimensional Arrays
2- Dimensional Arrays2- Dimensional Arrays
2- Dimensional Arrays
 
An overview of Python 2.7
An overview of Python 2.7An overview of Python 2.7
An overview of Python 2.7
 

More from fasttrackcomputersol

You have just been promoted to the job of CIO for Disney in Orlando,.pdf
You have just been promoted to the job of CIO for Disney in Orlando,.pdfYou have just been promoted to the job of CIO for Disney in Orlando,.pdf
You have just been promoted to the job of CIO for Disney in Orlando,.pdf
fasttrackcomputersol
 
Which one of the following theories is associated with the interactio.pdf
Which one of the following theories is associated with the interactio.pdfWhich one of the following theories is associated with the interactio.pdf
Which one of the following theories is associated with the interactio.pdf
fasttrackcomputersol
 
What types of cells do Endostatins go afterSolutionEndostatin.pdf
What types of cells do Endostatins go afterSolutionEndostatin.pdfWhat types of cells do Endostatins go afterSolutionEndostatin.pdf
What types of cells do Endostatins go afterSolutionEndostatin.pdf
fasttrackcomputersol
 
What is the main role of traffic engineering in planning a VoIP s.pdf
What is the main role of traffic engineering in planning a VoIP s.pdfWhat is the main role of traffic engineering in planning a VoIP s.pdf
What is the main role of traffic engineering in planning a VoIP s.pdf
fasttrackcomputersol
 
What are important abiotic factors in functioning and biotic structu.pdf
What are important abiotic factors in functioning and biotic structu.pdfWhat are important abiotic factors in functioning and biotic structu.pdf
What are important abiotic factors in functioning and biotic structu.pdf
fasttrackcomputersol
 
What are the evolutionary advanteges of evolving radulaSolution.pdf
What are the evolutionary advanteges of evolving radulaSolution.pdfWhat are the evolutionary advanteges of evolving radulaSolution.pdf
What are the evolutionary advanteges of evolving radulaSolution.pdf
fasttrackcomputersol
 
Two parallel wires separated by 4.3 cm repel each other with a force .pdf
Two parallel wires separated by 4.3 cm repel each other with a force .pdfTwo parallel wires separated by 4.3 cm repel each other with a force .pdf
Two parallel wires separated by 4.3 cm repel each other with a force .pdf
fasttrackcomputersol
 
This is the second time I post this question. I got an incorrect ans.pdf
This is the second time I post this question. I got an incorrect ans.pdfThis is the second time I post this question. I got an incorrect ans.pdf
This is the second time I post this question. I got an incorrect ans.pdf
fasttrackcomputersol
 
The virtualization concept is used at many levels and for various re.pdf
The virtualization concept is used at many levels and for various re.pdfThe virtualization concept is used at many levels and for various re.pdf
The virtualization concept is used at many levels and for various re.pdf
fasttrackcomputersol
 
Step by step procedures how layout is created and used for transistor.pdf
Step by step procedures how layout is created and used for transistor.pdfStep by step procedures how layout is created and used for transistor.pdf
Step by step procedures how layout is created and used for transistor.pdf
fasttrackcomputersol
 
Show all work. I need to know exactly how you got what you got so I .pdf
Show all work. I need to know exactly how you got what you got so I .pdfShow all work. I need to know exactly how you got what you got so I .pdf
Show all work. I need to know exactly how you got what you got so I .pdf
fasttrackcomputersol
 
Identify the three main threats to biodiversity and explain how each.pdf
Identify the three main threats to biodiversity and explain how each.pdfIdentify the three main threats to biodiversity and explain how each.pdf
Identify the three main threats to biodiversity and explain how each.pdf
fasttrackcomputersol
 
Q6. Proteins are used for structural integrity inside and outside of.pdf
Q6. Proteins are used for structural integrity inside and outside of.pdfQ6. Proteins are used for structural integrity inside and outside of.pdf
Q6. Proteins are used for structural integrity inside and outside of.pdf
fasttrackcomputersol
 
Python question...Complete without importing any modules. Ie. Don.pdf
Python question...Complete without importing any modules. Ie. Don.pdfPython question...Complete without importing any modules. Ie. Don.pdf
Python question...Complete without importing any modules. Ie. Don.pdf
fasttrackcomputersol
 
Please read the following IEEE Spectrum articles and answer the quest.pdf
Please read the following IEEE Spectrum articles and answer the quest.pdfPlease read the following IEEE Spectrum articles and answer the quest.pdf
Please read the following IEEE Spectrum articles and answer the quest.pdf
fasttrackcomputersol
 
Perform a search on the Web for articles and stories about social en.pdf
Perform a search on the Web for articles and stories about social en.pdfPerform a search on the Web for articles and stories about social en.pdf
Perform a search on the Web for articles and stories about social en.pdf
fasttrackcomputersol
 
Hospital Management Project Simple Scenario We want to develop a.pdf
Hospital Management Project Simple Scenario We want to develop a.pdfHospital Management Project Simple Scenario We want to develop a.pdf
Hospital Management Project Simple Scenario We want to develop a.pdf
fasttrackcomputersol
 
Explain a) advantage of promoting outcrossing in plants and preventi.pdf
Explain a) advantage of promoting outcrossing in plants and preventi.pdfExplain a) advantage of promoting outcrossing in plants and preventi.pdf
Explain a) advantage of promoting outcrossing in plants and preventi.pdf
fasttrackcomputersol
 
Essay question Camels must cope with hot desert environments where w.pdf
Essay question Camels must cope with hot desert environments where w.pdfEssay question Camels must cope with hot desert environments where w.pdf
Essay question Camels must cope with hot desert environments where w.pdf
fasttrackcomputersol
 
Describe the excel equation that you can use to measure the volumes l.pdf
Describe the excel equation that you can use to measure the volumes l.pdfDescribe the excel equation that you can use to measure the volumes l.pdf
Describe the excel equation that you can use to measure the volumes l.pdf
fasttrackcomputersol
 

More from fasttrackcomputersol (20)

You have just been promoted to the job of CIO for Disney in Orlando,.pdf
You have just been promoted to the job of CIO for Disney in Orlando,.pdfYou have just been promoted to the job of CIO for Disney in Orlando,.pdf
You have just been promoted to the job of CIO for Disney in Orlando,.pdf
 
Which one of the following theories is associated with the interactio.pdf
Which one of the following theories is associated with the interactio.pdfWhich one of the following theories is associated with the interactio.pdf
Which one of the following theories is associated with the interactio.pdf
 
What types of cells do Endostatins go afterSolutionEndostatin.pdf
What types of cells do Endostatins go afterSolutionEndostatin.pdfWhat types of cells do Endostatins go afterSolutionEndostatin.pdf
What types of cells do Endostatins go afterSolutionEndostatin.pdf
 
What is the main role of traffic engineering in planning a VoIP s.pdf
What is the main role of traffic engineering in planning a VoIP s.pdfWhat is the main role of traffic engineering in planning a VoIP s.pdf
What is the main role of traffic engineering in planning a VoIP s.pdf
 
What are important abiotic factors in functioning and biotic structu.pdf
What are important abiotic factors in functioning and biotic structu.pdfWhat are important abiotic factors in functioning and biotic structu.pdf
What are important abiotic factors in functioning and biotic structu.pdf
 
What are the evolutionary advanteges of evolving radulaSolution.pdf
What are the evolutionary advanteges of evolving radulaSolution.pdfWhat are the evolutionary advanteges of evolving radulaSolution.pdf
What are the evolutionary advanteges of evolving radulaSolution.pdf
 
Two parallel wires separated by 4.3 cm repel each other with a force .pdf
Two parallel wires separated by 4.3 cm repel each other with a force .pdfTwo parallel wires separated by 4.3 cm repel each other with a force .pdf
Two parallel wires separated by 4.3 cm repel each other with a force .pdf
 
This is the second time I post this question. I got an incorrect ans.pdf
This is the second time I post this question. I got an incorrect ans.pdfThis is the second time I post this question. I got an incorrect ans.pdf
This is the second time I post this question. I got an incorrect ans.pdf
 
The virtualization concept is used at many levels and for various re.pdf
The virtualization concept is used at many levels and for various re.pdfThe virtualization concept is used at many levels and for various re.pdf
The virtualization concept is used at many levels and for various re.pdf
 
Step by step procedures how layout is created and used for transistor.pdf
Step by step procedures how layout is created and used for transistor.pdfStep by step procedures how layout is created and used for transistor.pdf
Step by step procedures how layout is created and used for transistor.pdf
 
Show all work. I need to know exactly how you got what you got so I .pdf
Show all work. I need to know exactly how you got what you got so I .pdfShow all work. I need to know exactly how you got what you got so I .pdf
Show all work. I need to know exactly how you got what you got so I .pdf
 
Identify the three main threats to biodiversity and explain how each.pdf
Identify the three main threats to biodiversity and explain how each.pdfIdentify the three main threats to biodiversity and explain how each.pdf
Identify the three main threats to biodiversity and explain how each.pdf
 
Q6. Proteins are used for structural integrity inside and outside of.pdf
Q6. Proteins are used for structural integrity inside and outside of.pdfQ6. Proteins are used for structural integrity inside and outside of.pdf
Q6. Proteins are used for structural integrity inside and outside of.pdf
 
Python question...Complete without importing any modules. Ie. Don.pdf
Python question...Complete without importing any modules. Ie. Don.pdfPython question...Complete without importing any modules. Ie. Don.pdf
Python question...Complete without importing any modules. Ie. Don.pdf
 
Please read the following IEEE Spectrum articles and answer the quest.pdf
Please read the following IEEE Spectrum articles and answer the quest.pdfPlease read the following IEEE Spectrum articles and answer the quest.pdf
Please read the following IEEE Spectrum articles and answer the quest.pdf
 
Perform a search on the Web for articles and stories about social en.pdf
Perform a search on the Web for articles and stories about social en.pdfPerform a search on the Web for articles and stories about social en.pdf
Perform a search on the Web for articles and stories about social en.pdf
 
Hospital Management Project Simple Scenario We want to develop a.pdf
Hospital Management Project Simple Scenario We want to develop a.pdfHospital Management Project Simple Scenario We want to develop a.pdf
Hospital Management Project Simple Scenario We want to develop a.pdf
 
Explain a) advantage of promoting outcrossing in plants and preventi.pdf
Explain a) advantage of promoting outcrossing in plants and preventi.pdfExplain a) advantage of promoting outcrossing in plants and preventi.pdf
Explain a) advantage of promoting outcrossing in plants and preventi.pdf
 
Essay question Camels must cope with hot desert environments where w.pdf
Essay question Camels must cope with hot desert environments where w.pdfEssay question Camels must cope with hot desert environments where w.pdf
Essay question Camels must cope with hot desert environments where w.pdf
 
Describe the excel equation that you can use to measure the volumes l.pdf
Describe the excel equation that you can use to measure the volumes l.pdfDescribe the excel equation that you can use to measure the volumes l.pdf
Describe the excel equation that you can use to measure the volumes l.pdf
 

Recently uploaded

Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
paigestewart1632
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 

Recently uploaded (20)

Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
Cognitive Development Adolescence Psychology
Cognitive Development Adolescence PsychologyCognitive Development Adolescence Psychology
Cognitive Development Adolescence Psychology
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 

Finish the program below that does several bit-wise manipulations of.pdf

  • 1. Finish the program below that does several bit-wise manipulations of C integers. Cut and paste the following: Finish the Program! You may only use the integer constants given at the beginning. (You may use whatever integers you wish in string constants as long as they are for printf()'s. For example the format string "0x%08X" is useful for printing hexadecimal integers.) You may only use the following integer operators: + - ++ -- << >> ~ | & < > = != == Sample output (32 bit): Sample output (64 bit): Solution mm: la $a3, array_A # base address for array_A loaded into $a3 la $a1, array_B # base address for array_B loaded into $a1 la $a2, array_C # base address for array_C loaded into $a2 li $t1, four # $t1 = four (row-size and loop end) li $s0, zero # i = 0; initialize first for loop loop1: li $s1, zero # j = 0; restart 2d for loop loop2:
  • 2. li $s2, zero # k = 0; restart third for loop sll $t2, $s0, two # $t2 = i * four (size of row of c) addu $t2, $t2, $s1 # $t2 = i * size(row) + j sll $t2, $t2, two # $t2 = computer memory unit offset of [i][j] addu $t2, $a2, $t2 # $t2 = computer memory unit offset of [i][j] lw $t4, 0($t2) # $t4 = two bytes of c[i][j] loop3: sll $t0, $s2, two # $t0 = k * four (size of row of b) addu $t0, $t0, $s1 # $t0 = k * size(row) + j sll $t0, $t0, two # $t0 = computer memory unit offset off [k][j] addu $t0, $a1, $t0 # $t0 = computer memory unit address of b[k][j] lw $t5, 0($t0) # $t5 = two bytes of b[k][j] sll $t0, $s0, two # $t0 = i * four (size of row of a) addu $t0, $t0, $s2 # $t0 = i * size(row) + k sll $t0, $t0, two # $t0 = computer memory unit offset of [i][k] addu $t0, $a3, $t0 # $t0 = computer memory unit address of a[i][k] lw $t6, 0($t0) # $t6 = two bytes of a[i][k] mul $t5, $t6, $t5 # $t5 = a[i][k] * b[k][j] add $t4, $t4, $t5 # $t4 = c[i][j] + a[i][k] * b[k][j] addiu $s2, $s2, one # $k = k + one bne $s2, $t1, loop3 #if (k != 4) attend loop3 sw $t4, 0($a2) # c[i][j] = $t4 #----------TEST------------- li $v0, 1 lw $a0, ($a2) syscall li $v0, 4 la $a0, new_row syscall #----------TEST------------- addiu $s1, $s1, one # $j = j + one addi $a2, $a2, 4 bne $s1, $t1, loop2 # if (j != 4) attend loop2 addiu $s0, $s0, one # $i = i + one bne $s0, $t1, loop1 # if (i != 32) attend L1 Exit:
  • 3. li $v0, 10 #exits syscall .data array_A: .word 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 array_B: .word 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 array_C: .word 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 output_row_string_C: .asciiz "Matrix C Output Row " colon_string: .asciiz ": mm: la $a3, array_A # base address for array_A loaded into $a3 la $a1, array_B # base address for array_B loaded into $a1 la $a2, array_C # base address for array_C loaded into $a2 li $t1, four # $t1 = four (row-size and loop end) li $s0, zero # i = 0; initialize first for loop loop1: li $s1, zero # j = 0; restart 2d for loop loop2: li $s2, zero # k = 0; restart third for loop sll $t2, $s0, two # $t2 = i * four (size of row of c) addu $t2, $t2, $s1 # $t2 = i * size(row) + j sll $t2, $t2, two # $t2 = computer memory unit offset of [i][j] addu $t2, $a2, $t2 # $t2 = computer memory unit offset of [i][j] lw $t4, 0($t2) # $t4 = two bytes of c[i][j] loop3: sll $t0, $s2, two # $t0 = k * four (size of row of b) addu $t0, $t0, $s1 # $t0 = k * size(row) + j sll $t0, $t0, two # $t0 = computer memory unit offset off [k][j] addu $t0, $a1, $t0 # $t0 = computer memory unit address of b[k][j] lw $t5, 0($t0) # $t5 = two bytes of b[k][j] sll $t0, $s0, two # $t0 = i * four (size of row of a) addu $t0, $t0, $s2 # $t0 = i * size(row) + k sll $t0, $t0, two # $t0 = computer memory unit offset of [i][k] addu $t0, $a3, $t0 # $t0 = computer memory unit address of a[i][k] lw $t6, 0($t0) # $t6 = two bytes of a[i][k] mul $t5, $t6, $t5 # $t5 = a[i][k] * b[k][j] add $t4, $t4, $t5 # $t4 = c[i][j] + a[i][k] * b[k][j]
  • 4. addiu $s2, $s2, one # $k = k + one bne $s2, $t1, loop3 #if (k != 4) attend loop3 sw $t4, 0($a2) # c[i][j] = $t4 #----------TEST------------- li $v0, 1 lw $a0, ($a2) syscall li $v0, 4 la $a0, new_row syscall #----------TEST------------- addiu $s1, $s1, one # $j = j + one addi $a2, $a2, 4 bne $s1, $t1, loop2 # if (j != 4) attend loop2 addiu $s0, $s0, one # $i = i + one bne $s0, $t1, loop1 # if (i != 32) attend L1 Exit: li $v0, 10 #exits syscall .data array_A: .word 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 array_B: .word 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 array_C: .word 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 output_row_string_C: .asciiz "Matrix C Output Row " colon_string: .asciiz ":mm: la $a3, array_A # base address for array_A loaded into $a3 la $a1, array_B # base address for array_B loaded into $a1 la $a2, array_C # base address for array_C loaded into $a2 li $t1, four # $t1 = four (row-size and loop end) li $s0, zero # i = 0; initialize first for loop loop1: li $s1, zero # j = 0; restart 2d for loop loop2: li $s2, zero # k = 0; restart third for loop sll $t2, $s0, two # $t2 = i * four (size of row of c) addu $t2, $t2, $s1 # $t2 = i * size(row) + j
  • 5. sll $t2, $t2, two # $t2 = computer memory unit offset of [i][j] addu $t2, $a2, $t2 # $t2 = computer memory unit offset of [i][j] lw $t4, 0($t2) # $t4 = two bytes of c[i][j] loop3: sll $t0, $s2, two # $t0 = k * four (size of row of b) addu $t0, $t0, $s1 # $t0 = k * size(row) + j sll $t0, $t0, two # $t0 = computer memory unit offset off [k][j] addu $t0, $a1, $t0 # $t0 = computer memory unit address of b[k][j] lw $t5, 0($t0) # $t5 = two bytes of b[k][j] sll $t0, $s0, two # $t0 = i * four (size of row of a) addu $t0, $t0, $s2 # $t0 = i * size(row) + k sll $t0, $t0, two # $t0 = computer memory unit offset of [i][k] addu $t0, $a3, $t0 # $t0 = computer memory unit address of a[i][k] lw $t6, 0($t0) # $t6 = two bytes of a[i][k] mul $t5, $t6, $t5 # $t5 = a[i][k] * b[k][j] add $t4, $t4, $t5 # $t4 = c[i][j] + a[i][k] * b[k][j] addiu $s2, $s2, one # $k = k + one bne $s2, $t1, loop3 #if (k != 4) attend loop3 sw $t4, 0($a2) # c[i][j] = $t4 #----------TEST------------- li $v0, 1 lw $a0, ($a2) syscall li $v0, 4 la $a0, new_row syscall #----------TEST------------- addiu $s1, $s1, one # $j = j + one addi $a2, $a2, 4 bne $s1, $t1, loop2 # if (j != 4) attend loop2 addiu $s0, $s0, one # $i = i + one bne $s0, $t1, loop1 # if (i != 32) attend L1 Exit: li $v0, 10 #exits syscall .data
  • 6. array_A: .word 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 array_B: .word 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 array_C: .word 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 output_row_string_C: .asciiz "Matrix C Output Row " colon_string: .asciiz ": mm: la $a3, array_A # base address for array_A loaded into $a3 la $a1, array_B # base address for array_B loaded into $a1 la $a2, array_C # base address for array_C loaded into $a2 li $t1, four # $t1 = four (row-size and loop end) li $s0, zero # i = 0; initialize first for loop loop1: li $s1, zero # j = 0; restart 2d for loop loop2: li $s2, zero # k = 0; restart third for loop sll $t2, $s0, two # $t2 = i * four (size of row of c) addu $t2, $t2, $s1 # $t2 = i * size(row) + j sll $t2, $t2, two # $t2 = computer memory unit offset of [i][j] addu $t2, $a2, $t2 # $t2 = computer memory unit offset of [i][j] lw $t4, 0($t2) # $t4 = two bytes of c[i][j] loop3: sll $t0, $s2, two # $t0 = k * four (size of row of b) addu $t0, $t0, $s1 # $t0 = k * size(row) + j sll $t0, $t0, two # $t0 = computer memory unit offset off [k][j] addu $t0, $a1, $t0 # $t0 = computer memory unit address of b[k][j] lw $t5, 0($t0) # $t5 = two bytes of b[k][j] sll $t0, $s0, two # $t0 = i * four (size of row of a) addu $t0, $t0, $s2 # $t0 = i * size(row) + k sll $t0, $t0, two # $t0 = computer memory unit offset of [i][k] addu $t0, $a3, $t0 # $t0 = computer memory unit address of a[i][k] lw $t6, 0($t0) # $t6 = two bytes of a[i][k] mul $t5, $t6, $t5 # $t5 = a[i][k] * b[k][j] add $t4, $t4, $t5 # $t4 = c[i][j] + a[i][k] * b[k][j] addiu $s2, $s2, one # $k = k + one bne $s2, $t1, loop3 #if (k != 4) attend loop3 sw $t4, 0($a2) # c[i][j] = $t4
  • 7. #----------TEST------------- li $v0, 1 lw $a0, ($a2) syscall li $v0, 4 la $a0, new_row syscall #----------TEST------------- addiu $s1, $s1, one # $j = j + one addi $a2, $a2, 4 bne $s1, $t1, loop2 # if (j != 4) attend loop2 addiu $s0, $s0, one # $i = i + one bne $s0, $t1, loop1 # if (i != 32) attend L1 Exit: li $v0, 10 #exits syscall .data array_A: .word 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 array_B: .word 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 array_C: .word 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 output_row_string_C: .asciiz "Matrix C Output Row " colon_string: .asciiz ":