Monday, September 22, 2008

Lecture 6


 

  • IDEA for switch
    • Need to jump to right place in program or right label or right address
    • The label or address is dependent on what value of k
  • Unconditional Jump
    • Based on value of register = address to jump to is in the register
      • jr
        • jr , jump register
  • Modularity
  • Why use subprograms?
    • Easy to understand
    • Better organization
    • Reusable
    • Reduce complex tasks to simpler sets of task
    • Reliable, less errors
  • All programs are implemented / run sequentially
  • jal
    • jump and link procedure
      • jumps to a procedure address
      • saves the return address in $ra
  • jr
    • jump register
      • jump based on what is in $ra
  • $a0, $a1, $a2, $a3
    • Arguments
    • Caller calls the subprogram with arguments from $a*
    • The callee places subprograms result in $v0 and $v1
  • $ra
    • Return address
  • $sp
    • Stack pointer

The Stack


 

  • Procedure has only a total of 6 memory locations for data $a1-$a4 & $v0-$v1
  • A very specific kind of memory
    • It's in main memory but
    • Has a particular structure
    • It is a subset of main memory and it's run in a particular way
    • It has a top and a bottom but all we can do is push stuff on it and take stuff off the top of it

No comments: