Load -- read data from memory to register. Store -- write data from register to memory. Load effective address -- compute address, save in register

Similar documents
Ch. 5: The LC-3. PC-Relative Addressing Mode. Data Movement Instructions. James Goodman!

Introduction to Computer. Chapter 5 The LC-3. Instruction Set Architecture

Chapter 5 The LC-3. ACKNOWLEDGEMENT: This lecture uses slides prepared by Gregory T. Byrd, North Carolina State University 5-2

Introduction to Computer Engineering. CS/ECE 252, Fall 2016 Prof. Guri Sohi Computer Sciences Department University of Wisconsin Madison

EEL 5722C Field-Programmable Gate Array Design

Introduction to Computer Engineering. Chapter 5 The LC-3. Instruction Set Architecture

Computing Layers. Chapter 5 The LC-3

Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Computing Layers

COSC121: Computer Systems: Review

Instruction Set Architecture

COSC121: Computer Systems: Review

Introduction to Computer Engineering. CS/ECE 252, Spring 2017 Rahul Nayar Computer Sciences Department University of Wisconsin Madison

CS 2461: Computer Architecture I

Register Files. Single Bus Architecture. Register Files. Single Bus Processor. Term Project: using VHDL. Accumulator based architecture

20/08/14. Computer Systems 1. Instruction Processing: FETCH. Instruction Processing: DECODE

LC-3 Instruction Set Architecture

LC-3 Instruction Set Architecture. Textbook Chapter 5

Chapter 5 - ISA. 1.The Von Neumann Model. The Stored Program Computer. Von Neumann Model. Memory

10/31/2016. The LC-3 ISA Has Three Kinds of Opcodes. ECE 120: Introduction to Computing. ADD and AND Have Two Addressing Modes

LC-3 ISA - II. Lecture Topics. Lecture materials. Homework. Machine problem. Announcements. ECE 190 Lecture 10 February 17, 2011

The LC-3 Instruction Set Architecture. ISA Overview Operate instructions Data Movement instructions Control Instructions LC-3 data path

Midterm 2 Review Chapters 4-16 LC-3

ECE 206, Fall 2001: Lab 3

appendix a The LC-3 ISA A.1 Overview

LC-3. 3 bits for condition codes (more later) Fixed-length instructions, with 4-bit opcodes. IIT CS 350 S 18- Hale

Trap Vector Table. Interrupt Vector Table. Operating System and Supervisor Stack. Available for User Programs. Device Register Addresses

Memory Usage in Programs

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON. Instructor: Rahul Nayar TAs: Annie Lin, Mohit Verma

Logistics. IIT CS 350 S '17 - Hale

Chapter 6 Programming the LC-3

UNIVERSITY OF WISCONSIN MADISON

Chapter 9 TRAP Routines and Subroutines

Fortunately not. In LC-3, there are a variety of addressing modes that deal with these concerns.

System Calls. Chapter 9 TRAP Routines and Subroutines

Chapter 9 TRAP Routines and Subroutines

ECE/CS 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

Chapter 4 The Von Neumann Model

Intro. to Computer Architecture Homework 4 CSE 240 Autumn 2005 DUE: Mon. 10 October 2005

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

Microprogrammed Control. ECE 238L μseq 2006 Page 1

ADD R3, R4, #5 LDR R3, R4, #5

Binghamton University. CS-120 Summer LC3 Memory. Text: Introduction to Computer Systems : Sections 5.1.1, 5.3

Chapter 4 The Von Neumann Model

TRAPs and Subroutines. University of Texas at Austin CS310H - Computer Organization Spring 2010 Don Fussell

Introduction to Computer Engineering. CS/ECE 252, Spring 2017 Rahul Nayar Computer Sciences Department University of Wisconsin Madison

Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Review Topics

ECE/CS 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING COMPUTER SCIENCES DEPARTMENT UNIVERSITY OF WISCONSIN-MADISON

The Assembly Language of the Boz 5

Chapter 9 TRAP Routines and Subroutines

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING COMPUTER SCIENCES DEPARTMENT UNIVERSITY OF WISCONSIN-MADISON

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

CS 135: Computer Architecture I

11/10/2016. Review the Problem to Be Solved. ECE 120: Introduction to Computing. What Shall We Keep in the Registers? Where Are the Pieces in Memory?

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

Introduction to Computer Engineering. CS/ECE 252 Prof. Mark D. Hill Computer Sciences Department University of Wisconsin Madison

Chapter 4 The Von Neumann Model

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

LC-2 Programmer s Reference and User Guide

Copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Computing Layers

Subroutines & Traps. Announcements. New due date for assignment 2 5pm Wednesday, 5May

LC-3 Instruction Processing. (Textbook s Chapter 4)

LC-3 Architecture. (Ch4 ish material)

That is, we branch to JUMP_HERE, do whatever we need to do, and then branch to JUMP_BACK, which is where we started.

LC-3 Instruction Processing

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON

Implement useq's FSM's --- Next-state function --- Output function. We know: Any function can be implemented in AND-OR

CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON. Instructor: Rahul Nayar TAs: Mohit Verma, Annie Lin

Processor design - MIPS

EE 3170 Microcontroller Applications

Chapter 10 Computer Design Basics

Homework 06. Push Z Push Y Pop Y Push X Pop X Push W Push V Pop V Push U Pop U Pop W Pop Z Push T Push S

LC-3 Subroutines and Traps. (Textbook Chapter 9)"

Chapter 9 Computer Design Basics

CIT 593: Intro to Computer Systems Homework #4: Assembly Language Due October 18, 2012, 4:30pm. Name

Major and Minor States

Introduction to Computer Engineering. CS/ECE 252, Spring 2017 Rahul Nayar Computer Sciences Department University of Wisconsin Madison

Topic 10: Instruction Representation

Introduction to Computer Engineering. CS/ECE 252, Fall 2016 Prof. Guri Sohi Computer Sciences Department University of Wisconsin Madison

Chapter 5 (a) Overview

Review Topics. Midterm Exam Review Slides

William Stallings Computer Organization and Architecture 8 th Edition. Chapter 11 Instruction Sets: Addressing Modes and Formats

Chapter 04: Instruction Sets and the Processor organizations. Lesson 11: Generation of Memory Addresses and Addressing Modes

ECE 411 Exam 1. This exam has 5 problems. Make sure you have a complete exam before you begin.

11/6/2016. Let s Solve a Problem. ECE 120: Introduction to Computing. Overview of Our Task. Programs are Finite State Machines

CPE300: Digital System Architecture and Design

Binghamton University. CS-140 Fall Pippin

Review Topics. Midterm Exam Review Slides

Computer System. Hiroaki Kobayashi 7/25/2011. Agenda. Von Neumann Model Stored-program instructions and data are stored on memory

Processor Performance and Parallelism Y. K. Malaiya

Running Applications

Grundlagen Microcontroller Processor Core. Günther Gridling Bettina Weiss

EE 308: Microcontrollers

Module 5 - CPU Design

ECE 375 Computer Organization and Assembly Language Programming Winter 2018 Solution Set #2

Programming Studio #4 ECE 190

An FPGA Implementation of 8-bit RISC Microcontroller

Chapter 2 Instruction Set Architecture

Transcription:

Data Movement Instructions Load -- read data from memory to register LD: PC-relative mode LDR: base+offset mode LDI: indirect mode Store -- write data from register to memory ST: PC-relative mode STR: base+offset mode STI: indirect mode Load effective address -- compute address, save in register LEA: immediate mode does not access memory 5-13

PC-Relative Addressing Mode Want to specify address directly in the instruction But an address is 16 bits, and so is an instruction! After subtracting 4 bits for opcode and 3 bits for register, we have 9 bits available for address. Solution: Use the 9 bits as a signed offset from the current PC. 9 bits: 256 offset + 255 Can form any address X, such that: t PC 256 X PC + 255 Remember that PC is incremented as part of the FETCH phase; This is done before the EVALUATE ADDRESS stage. 5-14

LD (PC-Relative) 5-15

ST (PC-Relative) 5-16

Indirect Addressing Mode With PC-relative mode, can only address data within 256 words of the instruction. What about the rest of memory? Solution #1: Read address from memory location, then load/store to that address. First address is generated from PC and IR (just like PC-relative addressing), then content of that address is used as target for load/store. 5-17

LDI (Indirect) 5-18

STI (Indirect) 5-19

Base + Offset Addressing Mode With PC-relative mode, can only address data within 256 words of the instruction. What about the rest of memory? Solution #2: Use a register to generate a full 16-bit address. 4 bits for opcode, 3 for src/dest register, 3 bits for base register -- remaining 6 bits are used as a signed offset. Offset is sign-extended before adding to base register. 5-20

LDR (Base+Offset) 5-21

STR (Base+Offset) 5-22

Load Effective Address Computes address like PC-relative (PC plus signed offset) and stores the result into a register. Note: The address is stored in the register, not the contents of the memory location. 5-23

LEA (Immediate) 5-24

Example Address Instruction Comments x30f6 1 1 1 0 0 0 1 1 1 1 1 1 1 1 0 1 R1 PC 3 = x30f4 x30f7 0 0 0 1 0 1 0 0 0 1 1 0 1 1 1 0 R2 R1 + 14 = x3102 x30f8 0 0 1 1 0 1 0 1 1 1 1 1 1 0 1 1 M[PC - 5] R2 M[x30F4] x3102 x30f9 0 1 0 1 0 1 0 0 1 0 1 0 0 0 0 0 R2 0 x30fa 0 0 0 1 0 1 0 0 1 0 1 0 0 1 0 1 R2 R2 + 5 = 5 x30fb 0 1 1 1 0 1 0 0 0 1 0 0 1 1 1 0 x30fc 1 0 1 0 0 1 1 1 1 1 1 1 0 1 1 1 opcode M[R1+14] R2 M[x3102] 5 R3 M[M[x30F4]] R3 M[x3102] R3 5 5-25

Control Instructions Used to alter the sequence of instructions (by changing the Program Counter) Conditional Branch branch is taken if a specified condition is true signed offset is added to PC to yield new PC else, the branch is not taken PC is not changed, points to the next sequential instruction Unconditional Branch (or Jump) always changes the PC TRAP changes PC to the address of an OS service routine routine will return control to the next instruction (after TRAP) 5-26

Condition Codes LC-3 has three condition code registers: N -- negative Z -- zero P -- positive (greater than zero) Set by any instruction that writes a value to a register (ADD, AND, NOT, LD, LDR, LDI, LEA) Exactly one will be set at all times Based on the last instruction that altered a register 5-27

Branch Instruction Branch specifies one or more condition codes. If the set bit is specified, the branch is taken. PC-relative addressing: target address is made by adding signed offset (IR[8:0]) to current PC. Note: PC has already been incremented by FETCH stage. Note: Target must be within 256 words of BR instruction. If the branch is not taken, the next sequential instruction is executed. 5-28