Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Loop unrolling
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==== Converting to MIPS assembly language ==== The following is MIPS assembly code that will compute the dot product of two 100-entry vectors, A and B, before implementing loop unrolling. The code below omits the loop initializations: * Initialize loop count ($7) to 100. * Initialize dot product ($f8) to 0. * Initialize <code>A[i]</code> pointer ($5) to the base address of <code>A</code>. * Initialize <code>B[i]</code> pointer ($6) to the base address of <code>B</code>. Note that the size of one element of the arrays (a <code>double</code>) is 8 bytes.<syntaxhighlight lang="asm" line="1"> loop3: l.d $f10, 0($5) ; $f10 β A[i] l.d $f12, 0($6) ; $f12 β B[i] mul.d $f10, $f10, $f12 ; $f10 β A[i]*B[i] add.d $f8, $f8, $f10 ; $f8 β $f8 + A[i]*B[i] addi $5, $5, 8 ; increment pointer for A[i] by the size ; of a double. addi $6, $6, 8 ; increment pointer for B[i] by the size ; of a double. addi $7, $7, -1 ; decrement loop count test: bgtz $7, loop3 ; Continue if loop count > 0 </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)