Wednesday, September 17, 2008

Lecture 5

Lecture 5


 

  • Syscall
    • Used for input / output
    • Very primitive
    • Unique to system
    • Spim on unix
    • See text appendix A48 and the lesson number one
    • Invoked using syscall
    • $v0 will contain the service number (there are 10 services)
    • $a0..$a3 arguments
    • Print integer service number n = 1
  • Multiply In MIPS
    • mult rs, rt
  • Division in MIPS
    • div rs, rt
      • rs/rt
  • Structured loops
    • While (save[i] == k ) i = i+j
      • Loop in MIPS
  1. Get address of save[i]
  2. Load save[i]
  3. Go to exit if save != k
  4. I ß i+ j increment i
  5. Go to loop
  • Loop    

Add $t1, $s3, $s3

Add $t1, $t1, $t1

Lw $t0, 0($t1)

Bne $t0, $s5, exit

Add $s3, $s3, $s4

J loop

Exit:


 


 


 


 


 


 

  • Branch less than
  • Set on less than
    • Slt a, b, c
    • Set a to 1 when b < c
    • This was on the TEST we wrote TWO DAYS AGO. This guy needs a new job.

No comments: