2004 morgan kaufman publishers spring 2013 jan 25

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: ou guess what the field names stand for? 2004 © Morgan Kaufman Publishers Spring 2013, Jan 25 . . . Spring ELEC 5200-001/6200-001 Lecture 3 20 Violating Regularity for a Good Cause Times Square Grand Central Station Spring 2013, Jan 25 . . . Spring ELEC 5200-001/6200-001 Lecture 3 21 Machine Language Consider the load-word and store-word instructions, – What would the regularity principle have us do? – New principle: Good design demands a compromise Introduce a new type of instruction format – I-type for data transfer instructions – other format was R-type for register Example: lw $t0, 32($s2) Example: lw 35 18 9 opcode rs rt 32 16 bit number Where's the compromise? Spring 2013, Jan 25 . . . Spring ELEC 5200-001/6200-001 Lecture 3 2004 © Morgan Kaufman Publishers 22 Stored Program Concept Instructions are bits Programs are stored in memory Programs to be read or written just like data to Processor Memory memory for data, programs, compilers, editors, etc. Fetch and Execute Cycles Instructions are fetched and put into a special register Opcode bits in the register "control" the subsequent actions Fetch the “next” instruction and continue 2004 © Morgan Kaufman Publishers Spring 2013, Jan 25 . . . Spring ELEC 5200-001/6200-001 Lecture 3 23 Control Decision making instructions – alter the control flow, – i.e., change the "next" instruction to be executed MIPS conditional branch instructions: bne $t0, $t1, Label beq $t0, $t1, Label Example: Example: if (i==j) h = i + j; bne $s0, $s1, Label add $s3, $s0, $s1 Label: .... 2004 © Morgan Kaufman Publishers Spring 2013, Jan 25 . . . Spring ELEC 5200-001/6200-001 Lecture 3 24 Control MIPS unconditional branch instructions: j label Example: if (i!=j) beq $s4, $s5, Lab1 h=i+j; add $s3, $s4, $s5 else j Lab2 h=i-j; Lab1:sub $s3, $s4, $s5 Lab2: ... Can you build a simple for loop? loop 2004 © Morgan Kaufman Publishers Spring 2013, Jan 25 . . . Spring ELEC 5200-001/6200-001 Lecture 3 25 So Far We’ve Learned Instruction add $s1,$s2,$s3 sub $s1,$s2,$s3 lw $s1,100($s2) sw $s1,100($s2) bne $s4,$s5,Label beq $s4,$s5,Label j Label Formats: Meaning $s1 = $s2 + $s3 $s1 = $s2 – $...
View Full Document

This document was uploaded on 01/17/2014.

Ask a homework question - tutors are online