note t0 reg 8 t1 reg 9 s3 reg 19 s5 reg 21

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ote: $t0 ≡ Reg 8, $t1 ≡ Reg 9, $s3 ≡ Reg 19, $s5 ≡ Reg 21, $s6 ≡ Reg 22 temp temp i k save Spring 2013, Jan 25 . . . Spring ELEC 5200-001/6200-001 Lecture 3 39 Finding Branch Address Exit Finding Exit Exit = +2 is a 16 bit integer in bne instruction 000101 01000 10101 0000000000000010 = 2 $PC = 80016 is the byte address of the next instruction 00000000000000010011100010010000 = 80016 80016 Multiply bne argument by 4 (convert to byte address) 0000000000001000 = 8 $PC ← $PC + 8 $PC $PC 00000000000000010011100010011000 = 80024 00000000000000010011100010011000 80024 Thus, Exit is memory byte address 80024. Thus, Exit Spring 2013, Jan 25 . . . Spring ELEC 5200-001/6200-001 Lecture 3 40 Finding Jump Address Loop Finding Loop J 20000 000010 00000000000100111000100000 = 20000 $PC = 80024, when jump is being executed 00000000000000010011100010011000 = 80024 Multiply J argument by 4 (convert to byte address) 0000000000010011100010000000 = 80000 0000000000010011100010000000 Insert four leading bits from $PC 00000000000000010011100010000000 = 80000 Thus, Loop is memory byte address 80000. Thus, Loop Spring 2013, Jan 25 . . . Spring ELEC 5200-001/6200-001 Lecture 3 41 Summary: MIPS Registers and Summary: Memory Memory $s0-$s7, $t0-$t9, $zero, Fast locations for data. In MIPS, data m ust be in registers to perform 32 registers $a0-$a3, $v0-$v1, $gp, arithm etic. MIPS register $zero alw ays equals 0. Register $at is $fp, $sp, $ra, $at reserved for the assem bler to handle large constants. Memory[0], 230 memoryMemory[4], ..., words Memory[4294967292] Spring 2013, Jan 25 . . . Spring Accessed only by data transfer instructions. MIPS uses byte addresses, so sequential w ords differ by 4. Mem ory holds data structures, such as arrays, and spilled registers, such as those saved on procedure calls. ELEC 5200-001/6200-001 Lecture 3 42 Summary: MIPS Instructions MIPS assembly language Category add Example add $s1, $s2, $s3 Meaning $s1 = $s2 + $s3 Three operands; data in registers subtract sub $s1, $s2, $s3 $s1 = $s2 - $s3 Three operands; data in registers addi $s1, $s2, 100 lw $s1, 100($s2) sw $s1, 100($s2) lb $s1, 100($s2) sb $s1, 100($s2) lui $s1, 100 $s1 = $s2 + 100 Used to add constants $s1 = Memory[$s2 + 1 00]Word from memory to register Memory[$s2 + 100] = $s1 Word from register to memory $s1 = Memory[$s2 + 1 00]Byte from memory to register Memory[$s2 + 100] = $s1 Byte from register to memory $s1 = 100 * 2 16 Loads constant in upper 16 bits beq $s1, $s...
View Full Document

This document was uploaded on 01/17/2014.

Ask a homework question - tutors are online