Presentation is loading. Please wait.

Presentation is loading. Please wait.

MIPS Assembly Language Programming

Similar presentations


Presentation on theme: "MIPS Assembly Language Programming"— Presentation transcript:

1 MIPS Assembly Language Programming
CDA 3101 Fall 2010 Discussion Session 07 MIPS Assembly Language Programming 1 1

2 Instruction Register add $t0, $t1, $t2 ## RF[Rd] =RF[Rs] +RF[Rt]
Register – Format (add Rd, Rs, Rt)‏ Op-code Rs Rt Rd Shamt Function-code 6 5 5 5 5 6 add $t0, $t1, $t ## RF[Rd] =RF[Rs] +RF[Rt] 2 2 2

3 Instruction Register addi $t0, $t1, 100 ## RF[Rt] =RF[Rs] + se Imm
Immediate – Format (addi Rt, Rs, Imm)‏ Op-code Rs Rt Immediate 6 5 5 16 2’s Complement ? addi $t0, $t1, ## RF[Rt] =RF[Rs] + se Imm se Imm = {16 {immediate[15]}, immediate} beq Rs, Rt, Label ##if(RF[Rs] == Rf[Rt]) PC = PC +4 + BranchAddr* *BranchAddr = {14{immediate[15]}, immediate, 2’b0} 3 3 3

4 Instruction Register j Label ## PC = JumpAddr Jump– Format (j addr)‏
Op-code Address 6 26 j Label ## PC = JumpAddr JumpAddr = { PC[31:28], address, 2’b0} 4 4 4

5 Problem Assume the address start from 0x00400024, translate the
following MIPS code into the corresponding machine code. lable1: addi $t0, $0, x sll $t0, $t0, x bgez $t0, lable x C and $s0, $s0, $t x lable2: bne $s0, $0, lable3 0x lb $t4, 8($s4) x sb $t4, -8($s4) x C lable3: j lable x 5 5 5

6 Problem [0x ] ;addi $8, $0, 1 [0x ] ;sll $8, $8, 2 [0x c] ;bgez $8 -12 [lable1-0x c - 4] [0x ] ;and $16, $16, $8 [0x ] ;bne $16, $0, 8 [lable3-0x ] [0x ] ;lb $12, 8($20) [0x c] ;sb $12, -8($20) [0x ] ;j 0x [lable1] 6 6 6


Download ppt "MIPS Assembly Language Programming"

Similar presentations


Ads by Google