lect.03.Assembly2.4up

lect.03.Assembly2.4up - Announcements Urgent: sign up at...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
EE108b Lecture 3 C. Kozyrakis 1 EE108B – Lecture 3 MIPS Assembly Language II Christos Kozyrakis Stanford University http://eeclass.stanford.edu/ee108b EE108b Lecture 3 C. Kozyrakis 2 Announcements • Urgent: sign up at EEclass and say if you are taking 3 or 4 units • Homework #1 is available – Due on Tue 1/23, 5pm outside Gates 310 • Lab #1 is available – Due on Tuesday 1/30, midnight – Lab orientation after the class at Packard Hall • Programming assignment #1 will be available on Thursday • EE108B Review Session – Friday: 2:15pm-3:05pm in Thornton 102 EE108b Lecture 3 C. Kozyrakis 3 Review of MIPS Assembly Language I Instruction Set Architecture (ISA) – HW/SW interface – Multiple HW implementations of same interface Introduction to MIPS ISA and assembly programming – Register-register or load-store or RISC ISA Arithmetic (ALU) operations – add, sub, addu, subu – addi, addiu Quick reminders – What is the difference between add and addu? – What is the difference between addi and addu? – Why don’t we have subi or subiu instructions? EE108b Lecture 3 C. Kozyrakis 4 Review of MIPS Assembly Language I • Memory data transfer – displacement based addressing mode – lw, sw
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
EE108b Lecture 3 C. Kozyrakis 5 Today’s Menu • Finish Memory data transfer – Stores – Data alignment – Memory mapped I/O • Control transfer instructions – Branches and jumps • Machine language design – Binary encoding of assembly instructions – 3 MIPS instruction formats EE108b Lecture 3 C. Kozyrakis 6 Storing Data • Storing data is just the reverse and the instruction is nearly identical • Use the sw instruction to copy a word from the source register to an address in memory sw src, offset(base) • Offset value is signed EE108b Lecture 3 C. Kozyrakis 7 Storing Data Example • Consider the example *a = b + c; • Use the sw instruction to store add $t0, $s1, $s2 # $t0 = b + c sw $t0, 0($s0) # Memory[s0] = b + c EE108b Lecture 3 C. Kozyrakis 8 Storing to an Array • Consider the example a[3] = b + c; • Use the sw instruction offset add $t0, $s1, $s2 # $t0 = b + c sw $t0, 12($s0) # Memory[a[3]] = b + c
Background image of page 2
EE108b Lecture 3 C. Kozyrakis 9 Complex Array Storage • Consider the example a[i] = b + c; • Use the sw instruction offset add $t0, $s1, $s2 # $t0 = b + c sll $t1, $s3, 2 # $t1 = 4 * i add $t2, $s0, $t1 # $t2 = a + 4*i sw $t0, 0($t2) # Memory[a[i]] = b + c EE108b Lecture 3 C. Kozyrakis 10 A “short” Array Example • ANSI C requires a short to be at least 16 bits and no longer than an int, but does not define the exact size • For our purposes, treat a short as 2 bytes • So, with a short array c[7] is at c + 7 * 2, shift left by 1 c[7] c[6] c[5] c[4] c[3] c[2] c[1] c[0] 1000 2 bytes c 1014 1004 1008 1012 1016 1002 1006 1010 EE108b Lecture 3 C. Kozyrakis 11 MIPS Integer Load/Store Instruction Example Meaning Comments load word lw $1, 8($2) $1=Mem[8+$2]
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/08/2011 for the course EE 108B at Stanford.

Page1 / 14

lect.03.Assembly2.4up - Announcements Urgent: sign up at...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online