File indexing completed on 2024-05-12 04:02:06

0001 <!DOCTYPE html>
0002 <html><head>
0003 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
0004 <title>highlight.asm-mips</title>
0005 <meta name="generator" content="KF5::SyntaxHighlighting - Definition (MIPS Assembler) - Theme (Breeze Light)"/>
0006 </head><body style="background-color:#ffffff;color:#1f1c1b"><pre>
0007 <span style="color:#898887"># A demonstration of some simple MIPS instructions</span>
0008 <span style="color:#898887"># used to test QtSPIM</span>
0009 
0010     <span style="color:#898887"># Declare main as a global function</span>
0011     <span style="color:#0057ae">.globl</span> main 
0012 
0013     <span style="color:#898887"># All program code is placed after the</span>
0014     <span style="color:#898887"># .text assembler directive</span>
0015     <span style="font-weight:bold">.text</span>         
0016 
0017 <span style="color:#898887"># The label 'main' represents the starting point</span>
0018 <span style="color:#006e28">main:</span>
0019     <span style="color:#644a9b">li</span> <span style="color:#0000ff">$t2</span>, <span style="color:#b08000">25</span>     <span style="color:#898887"># Load immediate value (25) </span>
0020     <span style="font-weight:bold">lw</span> <span style="color:#0000ff">$t3</span>, value      <span style="color:#898887"># Load the word stored in value (see bottom)</span>
0021     <span style="font-weight:bold">add</span> <span style="color:#0000ff">$t4</span>, <span style="color:#0000ff">$t2</span>, <span style="color:#0000ff">$t3</span>    <span style="color:#898887"># Add</span>
0022     <span style="font-weight:bold">sub</span> <span style="color:#0000ff">$t5</span>, <span style="color:#0000ff">$t2</span>, <span style="color:#0000ff">$t3</span>    <span style="color:#898887"># Subtract</span>
0023     <span style="font-weight:bold">sw</span> <span style="color:#0000ff">$t5</span>, Z      <span style="color:#898887">#Store the answer in Z (declared at the bottom)  </span>
0024 
0025     <span style="color:#898887"># Exit the program by means of a syscall.</span>
0026     <span style="color:#898887"># There are many syscalls - pick the desired one</span>
0027     <span style="color:#898887"># by placing its code in $v0. The code for exit is "10"</span>
0028     <span style="color:#644a9b">li</span> <span style="color:#0057ae">$v0</span>, <span style="color:#b08000">10</span> <span style="color:#898887"># Sets $v0 to "10" to select exit syscall</span>
0029     <span style="font-weight:bold">syscall</span> <span style="color:#898887"># Exit</span>
0030 
0031     <span style="color:#898887"># All memory structures are placed after the</span>
0032     <span style="color:#898887"># .data assembler directive</span>
0033     <span style="font-weight:bold">.data</span>
0034 
0035     <span style="color:#898887"># The .word assembler directive reserves space</span>
0036     <span style="color:#898887"># in memory for a single 4-byte word (or multiple 4-byte words)</span>
0037     <span style="color:#898887"># and assigns that memory location an initial value</span>
0038     <span style="color:#898887"># (or a comma separated list of initial values)</span>
0039 <span style="color:#006e28">value:</span>   <span style="color:#0057ae">.word</span> <span style="color:#b08000">12</span>
0040 <span style="color:#006e28">Z:</span>   <span style="color:#0057ae">.word</span> <span style="color:#b08000">0</span>
0041 </pre></body></html>