05.08.2014 Views

Lecture Notes for Computer Architecture II - St. Cloud State University

Lecture Notes for Computer Architecture II - St. Cloud State University

Lecture Notes for Computer Architecture II - St. Cloud State University

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Problem<br />

Translate the following expression into MIPS assembly language<br />

<strong>for</strong> (i = 0; i < 100; i = i+1)<br />

a[i] = b[i]+c<br />

Solution<br />

<strong>St</strong>ep1 Assign variables to registers<br />

Page | 50<br />

i = $t 0<br />

1. i = 0<br />

2. a[i] = b[i]+c<br />

3. i = i+1<br />

4. i < 100<br />

complete the answer<br />

Instructions learned so far<br />

- add<br />

- sub<br />

- sw<br />

- beq<br />

- bne<br />

- slt<br />

- lw<br />

- j<br />

- jr<br />

- mult<br />

- slti<br />

Register notation in MIPS<br />

$zero – always has 0<br />

$t 0 - $t 7 – registers 8 to 15<br />

$S 0 - $S 7 – registers 16 to 23

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!