mips assembly l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
MIPS assembly PowerPoint Presentation
Download Presentation
MIPS assembly

Loading in 2 Seconds...

play fullscreen
1 / 7

MIPS assembly - PowerPoint PPT Presentation


  • 113 Views
  • Uploaded on

MIPS assembly. Exercise 2. How to implement this with only the instructions we learnt? if ($t1 > $t2) $t0 = $t1; else $t0 = $t2;. Exercise 2. # if ($t1 > $t2) $t0 = $t1; else $t0 = $t2; sub $t3, $t1, $t2 srl $t3, $t3, 31 bne $t3, $zero, L1 ori $t0, $t1, 0 j L2 L1:

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'MIPS assembly' - myra


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
exercise 2
Exercise 2
  • How to implement this with only the instructions we learnt?

if ($t1 > $t2)

$t0 = $t1;

else

$t0 = $t2;

exercise 23
Exercise 2

# if ($t1 > $t2) $t0 = $t1; else $t0 = $t2;

sub $t3, $t1, $t2

srl $t3, $t3, 31

bne $t3, $zero, L1

ori $t0, $t1, 0

j L2

L1:

ori $t0, $t2, 0

L2:

slt slti
slt, slti
  • slt $t3, $t1, $t2 – set $t3 to be 1 if $t1 < $t2; else clear $t3 to be 0. “Set Less Than.”
  • slti $t3, $t1, 100 – set $t3 to be 1 if $t1 < 100;

else clear $t3 to be 0.

  • Using slt, the code is simpler.
using slt
Using slt

slt $t3, $t1, $t2

bne $t3, $zero, L21

ori $t0, $t1, 0

j L22

L21:

ori $t0, $t2, 0

L22:

compiling a while loop in c
Compiling a while loop in C
  • How to translate the following to MIPS assembly?
    • We first translate into a C program using if and goto

week04-3.ppt

compiling a while loop in c7
Compiling a while loop in C
  • Assume that i and k correspond to registers $s3 and $s5 and starting address of array save is in $s6

week04-3.ppt