ECE232: Hardware Organization and Design

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

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

Unsigned Binary Integers

Unsigned Binary Integers

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

COMPSCI 313 S Computer Organization. 7 MIPS Instruction Set

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

ECE 331 Hardware Organization and Design. Professor Jay Taneja UMass ECE - Discussion 3 2/8/2018

Chapter 2A Instructions: Language of the Computer

Computer Architecture

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

MIPS%Assembly% E155%

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

Lecture 4: MIPS Instruction Set

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

CS3350B Computer Architecture MIPS Instruction Representation

ECE 154A Introduction to. Fall 2012

ECE260: Fundamentals of Computer Engineering

Chapter 2. Instructions:

Lecture 5: Procedure Calls

Instructions: Language of the Computer

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

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

ECE260: Fundamentals of Computer Engineering

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

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

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

Computer Architecture

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

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

Levels of Programming. Registers

Chapter 2: Instructions:

COMPUTER ORGANIZATION AND DESIGN

Topic Notes: MIPS Instruction Set Architecture

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

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

Typical Processor Execution Cycle

ECE 15B Computer Organization Spring 2010

Reduced Instruction Set Computer (RISC)

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

Computer Architecture. The Language of the Machine

Computer Organization MIPS Architecture. Department of Computer Science Missouri University of Science & Technology

MIPS Instruction Set Architecture (2)

ISA and RISCV. CASS 2018 Lavanya Ramapantulu

Reduced Instruction Set Computer (RISC)

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

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

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

Instruction Set Architecture part 1 (Introduction) Mehran Rezaei

5/17/2012. Recap from Last Time. CSE 2021: Computer Organization. The RISC Philosophy. Levels of Programming. Stored Program Computers

Recap from Last Time. CSE 2021: Computer Organization. Levels of Programming. The RISC Philosophy 5/19/2011

EEC 581 Computer Architecture Lecture 1 Review MIPS

MIPS ISA. 1. Data and Address Size 8-, 16-, 32-, 64-bit 2. Which instructions does the processor support

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

Math 230 Assembly Programming (AKA Computer Organization) Spring 2008

Computer Architecture. Lecture 2 : Instructions

ECE331: Hardware Organization and Design

Computer Architecture Instruction Set Architecture part 2. Mehran Rezaei

Instructions: Assembly Language

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

Control Instructions

Chapter 2. Instructions: Language of the Computer

CS/COE1541: Introduction to Computer Architecture

CSCI 402: Computer Architectures

Lectures 3-4: MIPS instructions

Chapter 2. Instruction Set Architecture (ISA)

Computer Architecture. MIPS Instruction Set Architecture

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

Course Administration

Architecture I. Computer Systems Laboratory Sungkyunkwan University

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

Overview. Introduction to the MIPS ISA. MIPS ISA Overview. Overview (2)

CMPE324 Computer Architecture Lecture 2

Computer Organization MIPS ISA

The MIPS Instruction Set Architecture

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

Instructions: Language of the Computer

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

CSSE232 Computer Architecture. Logic and Decision Opera:ons

CENG3420 Lecture 03 Review

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

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

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

Topics Power tends to corrupt; absolute power corrupts absolutely. Computer Organization CS Data Representation

MIPS Instruction Set

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

CS222: MIPS Instruction Set

CS3350B Computer Architecture

CS 4200/5200 Computer Architecture I

All instructions have 3 operands Operand order is fixed (destination first)

Five classic components

Mark Redekopp, All rights reserved. EE 357 Unit 11 MIPS ISA

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

ECE232: Hardware Organization and Design

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

Instruction Set Architectures Part I: From C to MIPS. Readings:

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

CS3350B Computer Architecture MIPS Introduction

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

Grading: 3 pts each part. If answer is correct but uses more instructions, 1 pt off. Wrong answer 3pts off.

Transcription:

ECE232: Hardware Organization and Design Lecture 4: Logic Operations and Introduction to Conditionals Adapted from Computer Organization and Design, Patterson & Hennessy, UCB

Overview Previously examined arithmetic operations R and I instructions formats Microprocessors also require logic operations NAND, OR, AND, etc Operations performed in the ALU Similar to logic operations Big picture Logic and arithmetic operations are fundamental to computer operation Introduction to conditional operations How computers make choices ECE232: Logic Operations + Intro to Conditionals 2

Typical Operations (little change since 1960) Data Movement Arithmetic Shift Logical Control (Jump/Branch) Subroutine Linkage Interrupt Graphics (MMX) Load (from memory) Store (to memory) register-to-register move input (from I/O device) output (to I/O device) push, pop (to/from stack) integer (binary + decimal) or FP Add, Subtract, Multiply, Divide shift left/right, rotate left/right not, and, or, set, clear unconditional, conditional call, return trap, return parallel subword ops (e.g., 4-16 bit add) ECE232: Logic Operations + Intro to Conditionals 3

MIPS Logical Instructions Instruction Example Meaning Comment and and $1,$2,$3 $1 = $2 & $3 3 reg. operands; Logical AND or or $1,$2,$3 $1 = $2 $3 3 reg. operands; Logical OR xor xor $1,$2,$3 $1 = $2 $3 3 operands; Logical XOR and immediate andi $1,$2,10 $1 = $2 & 10 Logical AND reg,constant or immediate ori $1,$2,10 $1 = $2 10 Logical OR reg, constant xor immediate xori $1, $2,10 $1 = $2 10 Logical XOR reg, constant shift left logical sll $1,$2,10 $1 = $2 << 10 Shift left by constant shift right logical srl $1,$2,10 $1 = $2 >> 10 Shift right by constant ECE232: Logic Operations + Intro to Conditionals 4

Logical Operations Instructions for bitwise manipulation Operation C Java MIPS Shift left << << sll Shift right >> >>> srl Bitwise AND & & and, andi Bitwise OR or, ori Bitwise NOT ~ ~ nor Useful for extracting and inserting groups of bits in a word ECE232: Logic Operations + Intro to Conditionals 5

Shift Operations op rs rt rd shamt funct 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits shamt: how many positions to shift Shift left logical Shift left and fill with 0 bits sll by i bits multiplies by 2 i Shift right logical Shift right and fill with 0 bits srl by i bits divides by 2 i (unsigned only) ECE232: Logic Operations + Intro to Conditionals 6

AND Operations Useful to mask bits in a word Select some bits, clear others to 0 and $t0, $t1, $t2 $t2 $t1 $t0 0000 0000 0000 0000 0000 1101 1100 0000 0000 0000 0000 0000 0011 1100 0000 0000 0000 0000 0000 0000 0000 1100 0000 0000 ECE232: Logic Operations + Intro to Conditionals 7

OR Operations Useful to include bits in a word Set some bits to 1, leave others unchanged or $t0, $t1, $t2 $t2 $t1 $t0 0000 0000 0000 0000 0000 1101 1100 0000 0000 0000 0000 0000 0011 1100 0000 0000 0000 0000 0000 0000 0011 1101 1100 0000 ECE232: Logic Operations + Intro to Conditionals 8

NOT Operations Useful to invert bits in a word Change 0 to 1, and 1 to 0 MIPS has NOR 3-operand instruction a NOR b == NOT ( a OR b ) nor $t0, $t1, $zero Register 0: always read as zero $t1 $t0 0000 0000 0000 0000 0011 1100 0000 0000 1111 1111 1111 1111 1100 0011 1111 1111 ECE232: Logic Operations + Intro to Conditionals 9

MIPS Registers and Usage Name Register number Usage $zero 0 the constant value 0 $at 1 reserved for assembler $v0-$v1 2-3 values for results and expression evaluation $a0-$a3 4-7 arguments $t0-$t7 8-15 temporary registers $s0-$s7 16-23 saved registers $t8-$t9 24-25 more temporary registers $k0-$k1 26-27 reserved for Operating System kernel $gp 28 global pointer $sp 29 stack pointer $fp 30 frame pointer $ra 31 return address ECE232: Logic Operations + Intro to Conditionals 10

Conditional Operations Branch to a labeled instruction if a condition is true Otherwise, continue sequentially beq rs, rt, L1 if (rs == rt) branch to instruction labeled L1; bne rs, rt, L1 if (rs!= rt) branch to instruction labeled L1; j L1 unconditional jump to instruction labeled L1 ECE232: Logic Operations + Intro to Conditionals 11

{ MIPS Conditional Branch Instructions Conditional branches allow decision making beq R1, R2, LABEL if R1==R2 goto LABEL bne R3, R4, LABEL if R3!=R4 goto LABEL beq $s1, $s2, 25 if ($s1==$s2) PC = PC + 4 + 4*25 else PC = PC + 4 Example C Code if (i==j) goto L1; f = g + h; L1: f = f - i; Address of next sequential instruction Offset in bytes Assembly beq $s3, $s4, L1 add $s0, $s1, $s2 L1: sub $s0, $s0, $s3 ECE232: Logic Operations + Intro to Conditionals 12

Binary Representation - Branch 6 bits 5 bits 5 bits 16 bits op rs rt offset Branch instructions use I-Format offset is added to PC when branch is taken beq r0, r1, offset has the effect: Conversion to byte offset if (r0==r1) pc = pc + 4 + (offset << 2) else pc = pc + 4; Offset is specified in instruction words (why?) What is the range of the branch target addresses? ECE232: Logic Operations + Intro to Conditionals 13

Binary Representation - Jump 6 bits 26 bits op address Jump Instruction uses J-Format (op=2) What happens during execution? PC = PC[31:28] : (IR[25:0] << 2) Concatenate upper 4 bits of PC to form complete 32-bit address Conversion to byte offset ECE232: Logic Operations + Intro to Conditionals 14

if statement if ( condition ) { statements } # MIPS code for the condition expression #(if condition satisfied set $t0=1) beq $t0, $zero, if_end_label # MIPS code for the statements if_end_label: ECE232: Logic Operations + Intro to Conditionals 15

Compiling If Statements C code: if (i==j) f = g+h; else f = g-h; f, g, in $s0, $s1, Compiled MIPS code: bne $s3, $s4, Else add $s0, $s1, $s2 j Exit Else: sub $s0, $s1, $s2 Exit: Assembler calculates addresses ECE232: Logic Operations + Intro to Conditionals 16

if else statement if ( condition ) { if-statements } else { else-statements } # MIPS code for the condition expression #(if condition satisfied set $t0=1) beq $t0, $zero, else_label # MIPS code for the if-statements j if_end_label else_label: # MIPS code for the else-statements if_end_label: ECE232: Logic Operations + Intro to Conditionals 17

Summary We have now covered the major operation instructions Most programs require lots of arithmetic and logic operations Can use registers or immediate operands Be sure to keep instruction formats in mind Control operations Modify the flow of the program What s next? Control operations programs require decisions Implementing control Implementing methods/subroutines ECE232: Logic Operations + Intro to Conditionals 18