Working With Main Memory. Why Main Memory Register space limited Used for communication.

Slides:



Advertisements
Similar presentations
Lecturer PSOE Dan Garcia
Advertisements

Lecture 13: 10/8/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Review of the MIPS Instruction Set Architecture. RISC Instruction Set Basics All operations on data apply to data in registers and typically change the.
CS/COE0447 Computer Organization & Assembly Language
Cosc 2150 Arrays in assembly code. Variables and addresses Uncompiled ld [a], %r1 addcc %r1, 2, %r3 ARC has three addressing modes —immediate, direct,
1 Procedure Calls, Linking & Launching Applications Lecture 15 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 5: Data Transfer Instructions / Control Flow Instructions Partially adapted from Computer.
SPIM and MIPS programming
1 Today’s lecture  Last lecture we started talking about control flow in MIPS (branches)  Finish up control-flow (branches) in MIPS —if/then —loops —case/switch.
MIPS Function Continued
MIPS Assembly Language Programming
The University of Adelaide, School of Computer Science
1 COMS 361 Computer Organization Title: Instructions Date: 9/28/2004 Lecture Number: 10.
Chap.2: Instructions: Language of the computer Jen-Chang Liu, Spring 2006 Adapted from
Normal C Memory Management °A program’s address space contains 4 regions: stack: local variables, grows downward heap: space requested for pointers via.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 4: Arithmetic / Data Transfer Instructions Partially adapted from Computer Organization.
Instruction Representation II (1) Fall 2007 Lecture 10: Instruction Representation II.
Lecture 5 Sept 14 Goals: Chapter 2 continued MIPS assembly language instruction formats translating c into MIPS - examples.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Hao Ji.
Data Transfer & Decisions I (1) Fall 2005 Lecture 3: MIPS Assembly language Decisions I.
Lecture 7: MIPS Instruction Set Today’s topic –Procedure call/return –Large constants Reminders –Homework #2 posted, due 9/17/
Instruction Set Architecture Basics. Our Progress Done with levels 0 and 1 Seen multiple examples of level 2 Ready for ISA general principles.
CSE378 Instr. encoding.1 Instruction encoding The ISA defines –The format of an instruction (syntax) –The meaning of the instruction (semantics) Format.
CSCI 136 Lab 1: 135 Review.
Character Data and 32-bit Constants (Lecture #20) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying.
Lecture 8. MIPS Instructions #2 – Memory Access (Load/Store) Instructions Prof. Taeweon Suh Computer Science Education Korea University 2010 R&E Computer.
Lecture 4. MIPS Instructions #2 Memory Access (Load/Store) Instructions Prof. Taeweon Suh Computer Science Education Korea University ECM534 Advanced Computer.
Computer Organization – Memory Access David Monismith Jan. 30, 2015 Based upon notes by Dr. Bill Siever and the Patterson and Hennessy Text.
Ch2b- 2 EE/CS/CPE Computer Organization  Seattle Pacific University Thanks for all the Memory! When 32 registers just won’t do. Many times (almost.
1 CS/COE0447 Computer Organization & Assembly Language Chapter 2 Part 2.
MIPS coding. slt, slti slt $t3, $t1, $t2 – set $t3 to be 1 if $t1 < $t2 ; else clear $t3 to be 0. – “Set Less Than.” slti $t3, $t1, 100 – set $t3 to be.
Chapter 2 — Instructions: Language of the Computer — 1 Memory Operands Main memory used for composite data – Arrays, structures, dynamic data To apply.
Chapter 2 — Instructions: Language of the Computer — 1 Conditional Operations Branch to a labeled instruction if a condition is true – Otherwise, continue.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 7, 8 Instruction Set Architecture.
Addressing Modes. Register Addressing Immediate Addressing Base Addressing Indexed Addressing PC-Relative Addressing.
MIPS Instruction Set Architecture Prof. Sirer CS 316 Cornell University.
Arrays in MIPS Assembly Computer Organization and Assembly Language: Module 6.
Home Assignment 5 Assigned. Deadline 2016 March 2, Wednesday.
Address alignment When a word (4-bytes) is loaded or stored the memory address must be a multiple of four. This is called an alignment restriction. Addresses.
Binary IO Writing and Reading Raw Data. Files Two major flavors of file: Text Binary.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Arrays and Pointers Variables are just names of memory locations An array is a variable (just with many memory locations – all contiguous) Address = pointer.
Memory Access Instructions Load and Store Addressing Modes Memory Addressing. Base addressing mode. Load byte and store byte: lb, lbu, sb Address alignment.
MIPS Arithmetic is 32 bits
CS/COE 0447 (term 2181) Jarrett Billingsley
Memory Access Instructions
Lecture 6: Assembly Programs
Lecture 7: MARS, Computer Arithmetic
Loading a Single Byte There are two instructions that load a byte from a memory address. The instructions differ in how the 8-bit byte is put into the.
Morgan Kaufmann Publishers
MPIS Instructions Functionalities of instructions Instruction format
ARM Memory.
CSCI206 - Computer Organization & Programming
The University of Adelaide, School of Computer Science
Computer Architecture & Operations I
Lecture 7: Examples, MARS, Arithmetic
Instruction encoding The ISA defines Format = Encoding
Computer Instructions
Computer Architecture
3.
Instruction encoding The ISA defines Format = Encoding
Instruction encoding The ISA defines Format = Encoding
Reading and writing to data memory
MIPS Instruction Set Architecture
ARM Memory.
Instruction encoding The ISA defines Format = Encoding
Generalities for Assembly Language
MIPS Assembly Language Programming Computer Architecture
Conditional Branching (beq)
Presentation transcript:

Working With Main Memory

Why Main Memory Register space limited Used for communication

Sections of Code.data section Things to place into memory at start.text section Code Any order, can have multiple.text/.data segments

Defining Memory Memory described as words/bytes/asciiz, etc… Hex: Ascii

Endianess Endianess : bytes order of a word in main memory

Little vs Big Endian Big is "Normal": Little weird – Words in order – Bytes in a word backwards

Integers Normal… Both endians store words (integers) same way – Disagree about how bytes are numbered

Single Byte Structures Agree on address of single byte structures – Just look different

Endian MARS is little endian: – Bytes/strings look goofy – Words (integers) unaffected

Why? Little Endian – Read different sized value at same address Big Endian – Easier to read hex – Reading start of word gives sign/magnitude

Base Register Data starts in defined location – 0x for MARS – 0x for reading simulator

Finding Memory Memory reference consist of offset(base) – base address : start here – offset : Go forward this many bytes 6(0x )

Arrays C++ Array – Base address – Offset : number of elements int quiz[3]; quiz[1] = 5;

Load Word / Store Word Memory access – lw : get word from memory – put in register – sw : put register value into memory lw $targetRegister, offset($baseAddressRegister) lw $9, 12($8) – Start from address in register $8 Should have 0x – Move over 16 bytes from there – Read a word into $9

LUI & Base Register lw $9, 12($8) Need address of.text section (0x ) in register Could do: ori $8, $0, 0x1001 sll $8, $8, 16

LUI & Base Register lui : load upper immediate – Place pattern in upper half of register lui $8, 0x1001 

Offsets Locations in order declared: x : 0(0x ) y: 4(0x )

Accessing Memory x = x + y where x and y are in main memory:

Load Delay Load delay: Can't use register in instruction after it is loaded – Real MIPS hardware – Tutorial's SPIM simulator – Don't worry about for MARS

Labels Labels usually used to specify memory locations – Not allowed for now

Labels Behind the scenes… – lw/sw with label = 2 instructions

Weirdness sizeof(2 chars and an int) != sizeof(2 chars and an int)

Memory Alignment Memory alignment : restrictions on where read/write can start – Want to read 4 bytes: Start on multiple of 4 – Want to read 2 bytes: Start on multiple of 2 – Want to read 1 byte: Start on any byte

Offsets Locations in order declared – Must be aligned

Offsets Locations in order declared – Must be aligned aa

Offsets Locations in order declared – Must be aligned aaff

Offsets Locations in order declared – Must be aligned aaff bb

Offsets Locations in order declared – Must be aligned aaff cc bb

Offsets Alternative order

Offsets Alternative order aa

Offsets Alternative order bbaa

Offsets Alternative order cc bbaa

Offsets Alternative order cc bbaaff

Byte Packing Byte packing : ordering class/struct members for proper alignment

Loading Bytes lb $dest, offset(base) : load byte sb $source, offset(base) : store byte lh $dest, offset(based) : load half word sh $ source, offset(base) : store half word

LB Sign Extension Code: Memory Result f f f f f f b b

Loading Bytes Loads sign extend value – Perfect for numeric data lbu/lhu load unsigned – no sign extension – use for chars, etc…

LB Sign Extension Code: Memory Result b b

Horner's Method Reduce multiplications to evaluate polynomial Ex: 6x 3 – 3x 2 + 7x + 2 First, put the coefficient of the first term into the accumulator: 6 Next, multiply that value by x: 6x Add the coefficient of the next term: 6x - 3 Next, multiply that sum by x: 6x 2 - 3x Add the coefficient of the next term: 6x 2 - 3x + 7 Next, multiply that sum by x: 6x 3 - 3x 2 + 7x Finally, add the coefficient of the last term: 6x 3 - 3x 2 + 7x + 2