L07-ac-lwswdecisions-6up - inst.eecs.berkeley.edu/~cs61c...

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

View Full Document Right Arrow Icon
CS61C L7 (1) Chae, Summer 2008 © UCB Albert Chae, Instructor inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #7 – MIPS: Load & Store, Decisions 2008-07-02 CS61C L7 (2) Chae, Summer 2008 © UCB Memory management review Three 3’s Picking blocks off free list - best-, first-, next-fit Attempts to solve external fragmentation - – Each of these suffer from external or internal fragmentation Automatic memory management - garbage collection - Reference Count: not for circular structures - Mark and Sweep: complicated and slow, works - Copying: Divides memory to copy good stuff Each technique has strengths and weaknesses, none is definitively best CS61C L7 (3) Chae, Summer 2008 © UCB MIPS intro review In MIPS Assembly Language: Registers replace C variables One Instruction (simple operation) per line Simpler is Better Smaller is Faster Basic instruction syntax op dest, src1, src2 New Instructions: add, addi, sub New Registers: C Variables: $s0 - $s7 Temporary Variables: $t0 - $t9 Zero: $zero CS61C L7 (4) Chae, Summer 2008 © UCB Assembly Operands: Memory C variables map onto registers; what about large data structures like arrays? 1 of 5 components of a computer: memory contains such data structures But MIPS arithmetic instructions only operate on registers, never directly on memory. Data transfer instructions transfer data between registers and memory: Memory to register Register to memory CS61C L7 (5) Chae, Summer 2008 © UCB Anatomy: 5 components of any Computer Personal Computer Processor Computer Control (“brain”) Datapath Registers Memory Devices Input Output Load (from) Load (from) Store (to) Store (to) These are “data transfer” instructions… Registers are in the datapath of the processor; if operands are in memory, we must transfer them to the processor to operate on them, and then transfer back to memory when done. CS61C L7 (6) Chae, Summer 2008 © UCB Data Transfer: Memory to Reg (1/4) To transfer a word of data, we need to specify two things: Register : specify this by # ($0 - $31) or symbolic name ($s0,…, $t0, …) Memory address : more difficult - Think of memory as a single one- dimensional array, so we can address it simply by supplying a pointer to a memory address. - Other times, we want to be able to offset from this pointer. Remember: “ Load FROM memory
Background image of page 1

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

View Full DocumentRight Arrow Icon
CS61C L7 (7) Chae, Summer 2008 © UCB Data Transfer: Memory to Reg (2/4) To specify a memory address to copy from, specify two things: A register containing a pointer to memory A numerical offset ( in bytes ) The desired memory address is the sum of these two values. Example:
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/06/2009 for the course CS cs61c taught by Professor Cory during the Summer '08 term at Berkeley College.

Page1 / 6

L07-ac-lwswdecisions-6up - inst.eecs.berkeley.edu/~cs61c...

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

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