CSSE 232 Computer Architecture I. I/O and Addressing

Similar documents
Character Is a byte quantity (00~FF or 0~255) ASCII (American Standard Code for Information Interchange) Page 91, Fig. 2.21

comp 180 Lecture 10 Outline of Lecture Procedure calls Saving and restoring registers Summary of MIPS instructions

CS 4200/5200 Computer Architecture I

MIPS (SPIM) Assembler Syntax

Course Administration

EEM 486: Computer Architecture. Lecture 2. MIPS Instruction Set Architecture

Computer Architecture

Reduced Instruction Set Computer (RISC)

Computer Science and Engineering 331. Midterm Examination #1. Fall Name: Solutions S.S.#:

CS/COE1541: Introduction to Computer Architecture

Computer Architecture. MIPS Instruction Set Architecture

1 5. Addressing Modes COMP2611 Fall 2015 Instruction: Language of the Computer

Reduced Instruction Set Computer (RISC)

CS3350B Computer Architecture MIPS Instruction Representation

Instructions: Language of the Computer

MIPS Instruction Set

Chapter 2: Instructions:

The MIPS Instruction Set Architecture

CS31001 COMPUTER ORGANIZATION AND ARCHITECTURE. Debdeep Mukhopadhyay, CSE, IIT Kharagpur. Instructions and Addressing

MIPS%Assembly% E155%

Chapter 2. Instructions: Language of the Computer. Adapted by Paulo Lopes

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA MIPS ISA. In a CPU. (vonneumann) Processor Organization

ECE232: Hardware Organization and Design. Computer Organization - Previously covered

M2 Instruction Set Architecture

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

CS3350B Computer Architecture MIPS Introduction

ELEC / Computer Architecture and Design Fall 2013 Instruction Set Architecture (Chapter 2)

Chapter 3 MIPS Assembly Language. Ó1998 Morgan Kaufmann Publishers 1

Computer Architecture. The Language of the Machine

Instructions: MIPS arithmetic. MIPS arithmetic. Chapter 3 : MIPS Downloaded from:

CS222: MIPS Instruction Set

ECE468 Computer Organization & Architecture. MIPS Instruction Set Architecture

CS3350B Computer Architecture

MIPS Reference Guide

MIPS R-format Instructions. Representing Instructions. Hexadecimal. R-format Example. MIPS I-format Example. MIPS I-format Instructions

MIPS Instruction Format

ICS 233 Computer Architecture & Assembly Language. ICS 233 Computer Architecture & Assembly Language

EE108B Lecture 3. MIPS Assembly Language II

Chapter 2. Computer Abstractions and Technology. Lesson 4: MIPS (cont )

CSCI 402: Computer Architectures. Instructions: Language of the Computer (3) Fengguang Song Department of Computer & Information Science IUPUI.

Chapter 2A Instructions: Language of the Computer

Instructions: Language of the Computer

101 Assembly. ENGR 3410 Computer Architecture Mark L. Chang Fall 2009

Control Instructions. Computer Organization Architectures for Embedded Computing. Thursday, 26 September Summary

Control Instructions


Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: MIPS Instruction Set Architecture

CENG3420 Lecture 03 Review

Unsigned Binary Integers

Unsigned Binary Integers

Assembly Language Programming. CPSC 252 Computer Organization Ellen Walker, Hiram College

Computer Organization MIPS ISA

Chapter 2. lw $s1,100($s2) $s1 = Memory[$s2+100] sw $s1,100($s2) Memory[$s2+100] = $s1

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

Lecture 2. Instructions: Language of the Computer (Chapter 2 of the textbook)

MIPS Memory Access Instructions

Chapter 2. Instruction Set Architecture (ISA)

CS61C - Machine Structures. Lecture 6 - Instruction Representation. September 15, 2000 David Patterson.

Computer Architecture

Review. Lecture #9 MIPS Logical & Shift Ops, and Instruction Representation I Logical Operators (1/3) Bitwise Operations

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: MIPS Instruction Set Architecture

Branch Addressing. Jump Addressing. Target Addressing Example. The University of Adelaide, School of Computer Science 28 September 2015

CSE 141 Computer Architecture Spring Lecture 3 Instruction Set Architecute. Course Schedule. Announcements

Instruction Set Architecture. "Speaking with the computer"

Introduction to the MIPS. Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University

ECE 30 Introduction to Computer Engineering

Lecture 4: MIPS Instruction Set

Instructions: MIPS ISA. Chapter 2 Instructions: Language of the Computer 1

Today s topics. MIPS operations and operands. MIPS arithmetic. CS/COE1541: Introduction to Computer Architecture. A Review of MIPS ISA.

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

EEC 581 Computer Architecture Lecture 1 Review MIPS

EE 361 University of Hawaii Fall

Topic Notes: MIPS Instruction Set Architecture

MIPS Coding Snippets. Prof. James L. Frankel Harvard University. Version of 9:32 PM 14-Feb-2016 Copyright 2016 James L. Frankel. All rights reserved.

Lectures 3-4: MIPS instructions

Lecture 5: Procedure Calls

Instruction Set Architecture of. MIPS Processor. MIPS Processor. MIPS Registers (continued) MIPS Registers

Stored Program Concept. Instructions: Characteristics of Instruction Set. Architecture Specification. Example of multiple operands

A Processor. Kevin Walsh CS 3410, Spring 2010 Computer Science Cornell University. See: P&H Chapter , 4.1-3

Chapter 2. Instructions: Language of the Computer. HW#1: 1.3 all, 1.4 all, 1.6.1, , , , , and Due date: one week.

bits 5..0 the sub-function of opcode 0, 32 for the add instruction

Machine Language Instructions Introduction. Instructions Words of a language understood by machine. Instruction set Vocabulary of the machine

ECE 2035 Programming HW/SW Systems Fall problems, 7 pages Exam Two 23 October 2013

ECE 15B Computer Organization Spring 2011

COMPUTER ORGANIZATION AND DESIGN

2.7 Supporting Procedures in hardware. Why procedures or functions? Procedure calls

MIPS ISA and MIPS Assembly. CS301 Prof. Szajda

Chapter 2. Instructions: Language of the Computer

Thomas Polzer Institut für Technische Informatik

I-Format Instructions (3/4) Define fields of the following number of bits each: = 32 bits

Instruction Set Architecture

Computer Architecture Instruction Set Architecture part 2. Mehran Rezaei

CSSE232 Computer Architecture. Logic and Decision Opera:ons

ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design

Instruction Set Architecture part 1 (Introduction) Mehran Rezaei

MACHINE LANGUAGE. To work with the machine, we need a translator.

ECE 15B Computer Organization Spring 2010

Midterm. Sticker winners: if you got >= 50 / 67

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

Review of the Machine Cycle

Transcription:

CSSE 232 Computer Architecture I I/O and Addressing 1 / 21

Class Status Reading for today 2.9-2.10, 6.6 (optional) 2 / 21

Outline I/O More memory instructions Addressing modes Jump and branch instructions 3 / 21

Input and Output How the processor communicates with the outside world Input Keyboard Mouse Network card Output Display / Graphics card Printer Network card Sound card 4 / 21

Performing I/O I/O port I/O devices are assigned to an I/O port Use specific I/O instructions to access I/O ports Memory-mapped I/O Reserve a portion of memory space for device I/O Use regular memory instructions to access 5 / 21

I/O ports I/O devices are assigned a port ID CPU has special instructions to read and write to I/O ports Data can then be sent and received by devices 6 / 21

Memory Mapped I/O Designate a portion of memory space to be for I/O Device memory and registers are mapped to this space Use normal memory instructions to read and write data A special piece of hardware monitors memory operations If regular memory space is accessed Read and write as normal If I/O space is accessed Intercept memory read/write Redirect to actual device memory I/O mapping can be disabled and addresses revert to regular memory 7 / 21

Polling and Interrupts Polling Devices set flag indicating they need to send/receive data Processor frequently polls devices Checks if any I/O devices need attention, responds Interrupt Device set interrupt flag and special status register Processor is forced to stop executing normal code Jumps to special interrupt handling code Responds to device interrupt 8 / 21

More Memory Instructions MIPS can work with other memory sizes: bytes, shorts lb : load byte into lowest register byte sb : store lowest register byte into memory lh : load half into bottom register half sh : store lower register half into memory ld : load double word sd : store double word Upper bits are sign extended 9 / 21

J-Type Last instruction type Used for jumps Jump only needs an address No other values op (6) target (26) 10 / 21

Addressing Modes Related instructions ori addi jr lw sw beq bne j 11 / 21

PC-Relative 2. Register Addressing addressing op rs rt rd... funct Branch address calculated as 3. 1 Base Sign addressing extend instruction constant 2opShift rs left rt 2 times Address (multiply by 4) 3 Sum result with PC (actually PC+4) Allows branching within ±2 15 instructions Register Example: beq, bne + Byte Registers Register Memory Halfword Word 4. PC-relative addressing op rs rt Address Memory PC + Word 5. Pseudodirect addressing op Address Memory 12 / 21

Program Counter (PC) Special register that points to current instruction jal saves PC+4 into $ra 13 / 21

Direct Addressing (also called Register) 1. Immediate addressing Register value allows access to 2 32 locations/values op rs rt Example: jr Immediate 2. Register addressing op rs rt rd... funct Registers Register 3. Base addressing op rs rt Address Memory Register + Byte Halfword Word 14 / 21

op rs rt Address Pseudo-Direct Addressing Memory Register + Byte Halfword Word Jump address is calculated as 4. 1 PC-relative Take 26 bits addressing from instruction constant 2opShift rs leftrt 2 times Address (multiply by 4) 3 Concat top 4 bits of the PC as MSBs Allows branching to 2 26 instructions Example: j PC + Memory Word 5. Pseudodirect addressing op Address Memory PC Word FIGURE 2.18 Illustration of the five MIPS addressing modes. The operands are shaded in colo The operand of mode 3 is in memory, whereas the operand for mode 2 is a register. Note that versions of lo and store access bytes, halfwords, or words. For mode 1, the operand is 16 bits of the instruction itself. Mod 4 and 5 address instructions in memory, with mode 4 adding a 16-bit address shifted left 2 bits to the 15 / PC 21 a

Immediate Addressing Operand is a constant within the instruction Some instructions sign extend (addi, slti) Some zero-extend (ori, andi, sltiu) Allows access to values in range [0, 2 16 ) or [ 2 15, 2 15 ) 1. Immediate addressing op rs rt Immediate 2. Register addressing op rs rt rd... funct Registers Register 3. Base addressing 16 / 21

Base / Displacement Addressing 1. Immediate addressing Memory address calculated as op rs rt Immediate 1 Sign extend instruction constant 2 Add to register value Register allows access to 2 32 locations 2. Register addressing Constant op rs allows rt rdaccess... funct to ±2 15 locations relative Registers to base Require word (4 byte) alignment: lw, sw 3. Base addressing Register op rs rt Address Memory Register + Byte Halfword Word 4. PC-relative addressing op rs rt Address Memory 17 / 21

Example What would be the machine language equivalent (in decimal) of the following code? Assume the Loop code starts on location 80000 in memory. Loop : s l l $t1, $s3, 2 add $t1, $t1, $s6 lw $t0, 0( $t1 ) bne $t0, $s5, Exit a d d i $s3, $s3, 1 j Loop Exit : 18 / 21

Example addr instruction format 80000 0 0 19 9 2 0 80004 0 9 22 9 0 32 80008 35 9 8 0 80012 5 8 21 2 80016 8 19 19 1 80020 2 20000 19 / 21

Branching Far Away What would you change if the bne statement needed to branch to 2 21 instructions before or after the branch? What would you change if the bne statement needed to branch to 2 30 instructions before or after the branch? 20 / 21

Branching Far Away What would you change if the bne statement needed to branch to 2 21 instructions before or after the branch? What would you change if the bne statement needed to branch to 2 30 instructions before or after the branch? Have the bne go to a beq, resulting in up 2 2 15 distance Have the bne go to a j, for a distance of 2 15 + 2 26 Load the goal address in a register and have the bne go to a jr 20 / 21

Review and Questions I/O More memory instructions Addressing modes Jump and branch instructions 21 / 21