Memory Access Instructions

Slides:



Advertisements
Similar presentations
Review of the MIPS Instruction Set Architecture. RISC Instruction Set Basics All operations on data apply to data in registers and typically change the.
Advertisements

CS/COE0447 Computer Organization & Assembly Language
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 5: Data Transfer Instructions / Control Flow Instructions Partially adapted from Computer.
ITCS 3181 Logic and Computer Systems 2015 B. Wilkinson slides3.ppt Modification date: March 16, Addressing Modes The methods used in machine instructions.
The University of Adelaide, School of Computer Science
Chap.2: Instructions: Language of the computer Jen-Chang Liu, Spring 2006 Adapted from
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 4: Arithmetic / Data Transfer Instructions Partially adapted from Computer Organization.
Lecture 5 Sept 14 Goals: Chapter 2 continued MIPS assembly language instruction formats translating c into MIPS - examples.
ARM programmer’s model and assembler Embedded Systems Programming.
Data Transfer & Decisions I (1) Fall 2005 Lecture 3: MIPS Assembly language Decisions I.
Topic 8: Data Transfer Instructions CSE 30: Computer Organization and Systems Programming Winter 2010 Prof. Ryan Kastner Dept. of Computer Science and.
Working With Main Memory. Why Main Memory Register space limited Used for communication.
Character Data and 32-bit Constants (Lecture #20) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying.
Instruction Set Architecture The portion of the machine visible to the programmer Issues: Internal storage model Addressing modes Operations Operands Encoding.
Computer Organization and Architecture Instructions: Language of the Machine Hennessy Patterson 2/E chapter 3. Notes are available with photocopier 24.
Chapter 2 CSF 2009 The MIPS Assembly Language: Introduction to Binary System.
Chapter 2 — Instructions: Language of the Computer — 1 Memory Operands Main memory used for composite data – Arrays, structures, dynamic data To apply.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 7, 8 Instruction Set Architecture.
MIPS Instruction Set Architecture Prof. Sirer CS 316 Cornell University.
Arrays in MIPS Assembly Computer Organization and Assembly Language: Module 6.
Jump and Branch Instructions
Computer Organization Instructions Language of The Computer (MIPS) 2.
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.
Assembly Variables: Registers Unlike HLL like C or Java, assembly cannot use variables – Why not? Keep Hardware Simple Assembly Operands are registers.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Memory Access Instructions Load and Store Addressing Modes Memory Addressing. Base addressing mode. Load byte and store byte: lb, lbu, sb Address alignment.
Microprocessors I 8051 Addressing Modes CS Prof. Msc. Ivan A. Escobar
MIPS Arithmetic is 32 bits
Data representation How do we represent data in a digital system?
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.
A Closer Look at Instruction Set Architectures
Morgan Kaufmann Publishers
MIPS Coding Continued.
ELEN 468 Advanced Logic Design
Conditional Branches What distinguishes a computer from a simple calculator is its ability to make decisions Decisions are made using the if statement,
Von Neumann model - Memory
Computer Organization and Assembly Language (COAL)
MIPS Assembly.
Appendix A Classifying Instruction Set Architecture
MPIS Instructions Functionalities of instructions Instruction format
Systems Architecture I (CS ) Lecture 5: MIPS Instruction Set*
CSCI206 - Computer Organization & Programming
The University of Adelaide, School of Computer Science
MIPS assembly.
Computer Architecture & Operations I
MIPS Instruction Encoding
MIPS Instruction Encoding
Instruction encoding The ISA defines Format = Encoding
Architecture Overview
Von Neumann model - Memory
CNET 315 Microprocessor & Assembly Language
Computer Instructions
Computer Architecture
September 17 Test 1 pre(re)view Fang-Yi will demonstrate Spim
3.
Instruction encoding The ISA defines Format = Encoding
Data representation How do we represent data in a digital system?
COMS 361 Computer Organization
Instruction encoding The ISA defines Format = Encoding
Introduction to Microprocessor Programming
COMS 361 Computer Organization
Reading and writing to data memory
MIPS Instruction Set Architecture
Instruction encoding The ISA defines Format = Encoding
MIPS Coding Continued.
Data representation How do we represent data in a digital system?
Systems Architecture I (CS ) Lecture 5: MIPS Instruction Set*
ARM Load/Store Instructions
MIPS Assembly.
Control Flow and Arrays
Presentation transcript:

Memory Access Instructions Load and Store Addressing Modes Memory Addressing. Base addressing mode. Load byte and store byte: lb, lbu, sb Address alignment. Big Endian, Little Endian. Load word. Store word. Load halfword. Store halfword. lw, sw, lh, lhu, sh Setting Up the base register Low order result. Portability problems Textbook P&H: Chapter 2.3,2.10, Appendix A Central Connecticut State University, MIPS Tutorial. Chapters 15,16.

Review: MIPS model 232 cells, each 8 bits MIPS memory is an array of 232 bytes. Each byte has a 32-bit address. Each byte can hold an 8-bit pattern, one of the 256 possible 8-bit patterns. The addresses of MIPS main memory range from 0x00000000 to 0xFFFFFFFF. 232 bytes Memory Size Operations Load: a bit pattern starting at a designated address in memory is copied into a register inside the processor. Store: a bit pattern is copied from a processor register to memory at a designated address. Address 32 bits General Purpose Register

Byte operations Load byte Memory byte -> Register byte Store byte 232 bytes Memory Size Load byte Memory byte -> Register byte Store byte Register byte -> Memory byte Address 32 bits Low order 3 2 1 0 General Purpose Register

Halfword operations Load halfword Store halfword Memory 2 bytes -> Register 2 bytes Store halfword Register 2 bytes -> Memory 2 bytes 232 bytes Memory Size Address 32 bits Low order 3 2 1 0 General Purpose Register

Word length operations Load word Memory 4 bytes -> Register 4 bytes Store word Register 4 bytes -> Memory 4 bytes 232 bytes Memory Size Address 32 bits Low order 3 2 1 0 General Purpose Register

Addressing Modes Addressing mode – One of several addressing regimes delimited by their varied use of operands and or addresses. The first two modes we have learned. 3. Base or displacement addressing, where the operand is at the memory location, whose address is the sum of a register and a constant in the instruction 2. Register addressing, where the operand is a register 1. Immediate addressing, where the operand is a constant within the instruction itself

Memory Instructions need Address & Register To transfer a word of data, we need to specify two things: Register: We specify this by # ($0 - $31) or symbolic name ($s0,…,$t0,…) Memory address: This is more difficult to specify. A MIPS instruction is 32 bits (always). A MIPS memory address is 32 bits (always). How can a load or store instruction specify an address that is the same size as itself ?

Offset and absolute address complicate our task Memory is a single one-dimensional array, so we can address it simply by supplying a pointer to a memory address. However very often, we want to be able to offset from this pointer. This is because sometimes we need only the relative address to refer to the memory starting from some current address. That relative address is called “offset”. +2 -3 Absolute pointer 0x00000006 Relative pointer(offset) +2 Relative pointer(offset) -3

Base address + Offset So for memory addressing we need: Either the absolute 32 bit address of the memory Or The offset (relative address) of the memory In this case to calculate the absolute address of the memory we need the offset and some current or base absolute address. +2 -3 Base Address = 0x00000006 Calculated address = 0x00000006+2=0x00000008 0x00000006-3=0x00000003

Where to keep the Base Address and Offset ? To specify a memory address specify two things: A register containing a base 32 bits address to memory A numerical offset in bytes in the instruction The desired memory address is the sum of these two values. Example: 8($t0) specifies the memory address pointed to by the value in $t0, plus 8 bytes

What looks like the memory access instruction ? Why sign extension ? offset lb rt, MemAaddress lb rt, offset (rs)

Addressing examples positive offset

Addressing examples negative offset