1 / 6

MIPS Assembly Language Programming

CDA 3101 Fall 2010 Discussion Session 07. MIPS Assembly Language Programming. 1. Instruction Register. Register – Format ( add Rd, Rs, Rt ) ‏. Op-code. Rs. Rt. Rd. Shamt. Function-code. 6. 5. 5. 5. 5. 6. add $t0, $t1, $ t2 ## RF[Rd] =RF[Rs] +RF[Rt]. 2.

shani
Télécharger la présentation

MIPS Assembly Language Programming

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

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

  3. Instruction Register Immediate – Format (addi Rt, Rs, Imm)‏ Op-code Rs Rt Immediate 6 5 5 16 2’s Complement ? addi $t0, $t1, 100 ## 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

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

  5. Problem Assume the address start from 0x00400024, translate the following MIPS code into the corresponding machine code. lable1: addi $t0, $0, 1 0x00400024 sll $t0, $t0, 2 0x00400028 bgez $t0, lable1 0x0040002C and $s0, $s0, $t0 0x00400030 lable2: bne $s0, $0, lable3 0x00400034 lb $t4, 8($s4) 0x00400038 sb $t4, -8($s4) 0x0040003C lable3: j lable10x00400040 5

  6. Problem [0x00400024] 001000 00000 01000 0000000000000001 ;addi $8, $0, 1 [0x00400028] 000000 00000 01000 01000 00010 000000 ;sll $8, $8, 2 [0x0040002c] 000001 01000 00001 1111111111111101 ;bgez $8 -12 [lable1-0x0040002c - 4] [0x00400030] 000000 10000 01000 10000 00000 100100 ;and $16, $16, $8 [0x00400034] 000101 10000 00000 00000000 0000 0010 ;bne $16, $0, 8 [lable3-0x00400034- 4] [0x00400038] 100000 10100 01100 0000000000001000 ;lb $12, 8($20) [0x0040003c] 101000 10100 01100 1111111111111000 ;sb $12, -8($20) [0x00400040] 000010 00 00010000 00000000 00001001 ;j 0x00400024 [lable1] 6

More Related