1 / 6

# MIPS Assembly Language Programming - PowerPoint PPT Presentation

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.

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

## PowerPoint Slideshow about ' MIPS Assembly Language Programming' - shani

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

Discussion Session 07

MIPS Assembly Language Programming

1

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

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*

3

Op-code

6

26

j Label ## PC = JumpAddr

4

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

[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