Levels of Programming. Registers
|
|
- Rolf Lester
- 5 years ago
- Views:
Transcription
1 Levels of Programming COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer Science York University Handout # 3: MIPS Instruction Set I Topics: 1. Arithmetic Instructions 2. Registers, Memory, and Addressing 3. Load/Save, Logical Operation Instructions 4. Representing MIPS as binary code 5. Instructions for making decisions Patterson: Sections Recall that a CPU can only understand binary machine language program Writing binary machine language program is cumbersome An intermediate solution is to write assembly language program that can easily be translated (assembled) to binary language programs In this course we will cover MIPS ISA used by NEC, Nintendo, Silicon Graphics, and Sony MIPS is more primitive than higher level languages with a very restrictive set of instructions 2 Fetch and Execute Registers Instructions are stored in the form of bits Programs are stored in memory and are read or written just like data Registers are memory cells In MIPS, data must be in registers before arithmetic operations can be performed Size of each register is 32 bits, referred to as a word (1 word = 4 bytes = 32 bits) MIPS has a total of 32 registers Processor Memory memory for data, programs, compilers, editors, etc. Fetch & Execute Cycle Instructions are fetched and put into a special register Bits in the register "control" the subsequent actions Data if required is fetched from the memory and placed in other registers Fetch the next instruction and continue 3 Name Register number Usage $zero 0 Constant value of 0 $v0-$v1 2-3 Values for results and expression evaluation $a0-$a3 4-7 Input arguments to a procedure $t0-$t Not preserved across procedures (temp) $s0-$s Preserved across procedure calls $t8-$t More temporary registers $gp 28 Global pointer $sp 29 Stack pointer, points to last location of stack $fp 30 Frame pointer $ra 31 Return address from a procedure call 4
2 Addition & Subtraction Memory Organization Arithmetic Example: C: f = (g + h) (i + j); Step 1: Specify registers containing variables Step 2: Express instruction in MIPS add add $s1,$s2,$s3 $s1 $s2+$s3 overflow detected subtract sub $s1,$s2,$s3 $s1 $s2-$s3 overflow detected $t0 - $t7 $s0 - $s7 $t0 g+h $t1 i+j $s0 $t2 final $s1 g $t3 $s2 h $t4 $s3 i $t5 $s4 j $s5 $s6 $s7 $t6 $t7 $t8 $t Memory can be viewed as a large one dimensional array of cells To access a cell, its address is required (Addresses are indices to the array) In MIPS, each cell is 1 word (4 bytes) long Each word in a memory has an address, which is a multiple of 4 Length of an address is 32 bits, hence minimum value of address = 0 maximum value of address = (2 32 1) Data is transferred from memory into registers using data transfer instructions MIPS code: $s1 add $t0,$s1,$s2 # $t0 $s1 + $s2 load word lw $s1,100($s2) Memory to Register memory[$s2+100] add $t1,$s3,$s4 # $t1 $s3 + $s4 Data transfer sub $t2,$t0,$t1 # $t2 $t0 - $t1 5 store word sw $s1,100($s2) memory[$s2+100] Register to memory $s1 6 Data Transfer Instructions Data transfer load word store word lw $s1,100($s2) sw $s1,100($s2) $s1 memory[$s2+100] memory[$s2+100] $s2 Memory to Register Register to memory So far we have learned MIPS loading words but addressing bytes addition and subtraction operations on registers only Instructions Meaning Example: C instruction: g = h + A[k] Register Allocation: $s1 contains computed value of g; $s2 contains value of h $s3 contains base address of array (address of A[0]) $s4 contains value of k; A[k] A[1] A[0] add $t1,$s4,$s4 # $t1 = 2 x k Array add $t1,$t1,$t1 # $t1 = 4 x k add $t1,$t1,$s3 # $t1 = address of A[0] + 4 x k lw $t0,0($t1) # $t0 = A[k] Add $s1,$s2,$t0 # $s3 = h + A[k] Address + 4xk address + 4 address D a t a 7 add $s1,$s2,$s3 # $s1 = $s2 + $s3 (arithmetic) sub $s1,$s2,$s3 # $s1 = $s2 $s3 (arithmetic) lw $s1,100($s2) # $s1 = Memory[$s2+100] (data transfer) sw $s1,100($s2) # Memory[$s2+100] = $s1 (data transfer) Activity 1: Write the MIPS assembly code for the following C assignment instruction A[12] = h + A[8] assuming that the variable h is stored in $s2 and the base address of the array A is in $s3. 8
3 Binary Representation A computer can only process bits. Characters, integers, and real numbers must be represented in bits. Different representation are labeled with a subscript. A decimal number is represented by subscript <ten>. Binary numbers are represented by subscript <two>. Hexadecimal numbers are represented by subscript <hex>. Examples: 987 ten, two, and 987 hex Case 1: Decimal to Binary Conversion Example: Convert 445 ten into 32-bit binary Binary Representation: 445 ten = two Case 2: Binary to Decimal Conversion Example: Convert two to decimal Hexadecimal Representation (1) Case 3: Decimal to Hexadecimal Conversion Example: Convert 445 ten into hexadecimal 445 ten = bd hex in 1 word Case 4: Hexadecimal to Decimal Conversion Example: Convert bd hex to decimal ( ) + ( b ) ( d ) e 14 = 445 ten 9 f = 445 ten d 1 b Hexa Decimal a 10 b 11 c 12 d 13 Hexadecimal Representation (2) 2 s Complement (1) Case 5: Hexadecimal to Binary Conversion Example: Convert bd hex into binary () 0 + () 0 + () 0 + () 0 + () 0 + () 0 + () 1 + () b + () d 0000 two 0000 two 0000 two 0000 two 0000 two 0000 two 0001 two 1011 two 1101 two MIPS uses 2 s complement to represent signed numbers In 2 s complement, a positive number is represented using a 31-bit binary number Example: +2 ten is represented as two or hex Case 6: Binary to Hexadecimal Conversion Example: Convert two to hexadecimal ( 0000 ) + ( 0000 ) + ( 0000 ) + ( 0000 ) + ( 0000 ) + ( 0000 ) + ( 0001 ) + ( 1011 ) + ( 1101 ) Activity 1: Convert 1998 ten into binary using the hexadecimal shortcut. 1 hex b hex d hex 11 In 2 s complement, a negative number X two is represented by taking the complement of its magnitude X two plus 1. Example: 2 ten Represent the magnitude in binary format 2 ten is represented as two Take the complement of each digit The results is two Add 1 to the LSB 2 ten is represented as two or fffffffe hex 12
4 2 s Complement (2) Unsigned and Signed Arithmetic 5. The MSB (32 nd bit) is in indication of sign. To convert a 32-bit number in 2 s complement to decimal ( b )+ ( b )+ ( b )+ + ( b1 2 1 )+ ( b0 2 0 ) Example: two is represented by two is represented by ( )+ ( )+ ( )+ + ( )+ ( )= 2 MIPS has a separate format for unsigned and signed integers Unsigned integers are saved as 32-bit words Example: Smallest unsigned integer is = 0 ten Largest unsigned integer is ffffffff hex = 4,294,967,295 ten Signed integers are saved as 32-bit words in 2 s complement with the MSB reserved for sign If MSB = 1, then the number is negative If MSB = 0, then the number is positive Example: Smallest signed integer: two = (2 31 ) 10 = 2,147,483, Largest signed integer: two = (231 1) 10 = 2,147,483, MIPS to Binary Machine Language (1) Example: add $t0,$s1,$s2 Binary Machine Language Equivalent: Can we derive the binary machine language code from the MIPS instruction? MIPS field for arithmetic instructions: op rs rt rd shamt funct 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits opcode 1 st operand 2 nd operand destination shift function MIPS Fields for Arithmetic Operations op rs rt rd shamt funct 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits opcode 1 st operand 2 nd operand destination shift function For arithmetic operations (R): Opcode (op) = 0 Function (funct) = 32 for add, 34 for sub Example: add $t0,$s1,$s2 (Values of Registers: $t0 = 9, $s1 = 17, $s2 = 18) op = 0 10 = (000000) 2 rs = = (10001) 2 rt = = (10010) 2 rd = 8 10 = (01000) 2 shamt is not used = (00000) 2 15 funct = = (100000) 2 leads to the binary machine language code:
5 MIPS Fields for Data Transfer Operations op rs rt address Example Activity 2: Consider the C instruction 6 bits 5 bits 5 bits 16 bits opcode 1 st operand 2 nd operand Memory address (offset) For data transfer operations (I): Opcode (op) = 35 for load (lw) and 43 for save (sw) A[300] = h + A[300] A. Write the equivalent MIPS code for the above C instruction assuming $t1 contains the base address of array A (i.e., address of A[0]) and $s2 contains the value of h B. Write the binary machine language code for the result in part A. Example: lw $t0,32($s3) # (Values of Registers: $t0 = 9, $s3 = 19) op = = (100011) 2 rs = = (10011) 2 rt = 8 10 = (01000) 2 address = = ( ) 2 leads to the binary machine language code: MIPS Branch Instructions for if (1) MIPS Branch Instructions for if (2) Branch if equal to: beq $s1,$s2,l1 # if $s1 == $s2, go to L1 Branch if not equal to: bne $s1,$s2,l2 # if $s1!= $s2, go to L2 Unconditional jump: j L3 # go to L3 Example: if (i == j) go to L1; f = g + h; L1: f = f i Assume that the five variables f, g, h, i, and j are stored in the registers: $s0 to $s4 if (i == j) f = g + h; else f = g - h; Assume that the five variables f, g, h, i, and j are stored in the registers: $s0 to $s4 bne $s3,$s4,l1 # go to L1 if i == j add $s0,$s1,$s2 # f = g + h j L2 # L1: sub $s0,$s0,$s2 # f = f I L2: beq $s3,$s4,l1 # go to L1 if i == j add $s0,$s1,$s2 # f = g + h Activity 3: Write the above code using branch if equal to statement? L1: sub $s0,$s0,$s3 # f = f - i 19 20
6 Loops (for) Loops (while) Loop: g = g + A[i] i = i + j; if (i!= h) goto Loop; Assume A is an array of 100 elements and that the compiler associates the variables g, h, i, and j are stored in the registers: $s1 to $s4. The base address of the array is contained in $s5. Loop: add $t1,$s3,$s3 #$t1 = 2 i add $t1,$t1,$t1 #$t1 = 4 i add $t1,$t1,$s5 #$t1 = address of A[i] lw $t0,0($t1) #$t0 = A[i] add $s3,$s3,$s4 #$s3 = i + j bne $s3,$s2,loop #go to Loop if (i!=h) while (save[i] == k) i = i + j; Assume that the variables i, j, and k are stored in the registers: $s3, $s4, and $s5. The base address of the array (save) is contained in $s6. What is the MIPS code? Loop: add $t1,$s3,$s3 #$t1 = 2 x i add $t1,$t1,$t1 #$t1 = 4 x i add $t1,$t1,$s6 #$t1 = address of save[i] lw $t0,0($t1) #$t0 = save[i] bne $t0,$s5,exit #go to Exit if save[i]!=k add $s3,$s3,$s4 #$s3 = i + j j Loop #go to Loop Exit: Loops (case/switch) Loops (case/switch) slt $t3,$s5,$zero #test if k<0 bne $t3,$zero,exit #if k<0, go to Exit slt $t3,$s5,$t2 #test if k<4 beq $t3,$zero,exit #if k >=4, go to Exit add $t1,$s5,$s5 #$t1 = 2 * k add $t1,$t1,$t1 #$t1 = 4 * k add $t1,$t1,$t4 #$t1 = &jumptable[k] lw $t0,0($t1) #$t0 = jumbtable[k] jr $t0 L0: add $s0,$s3,$s4 #$s0 = (i + j) L1: add $s0,$s1,$s2 #$s0 = (g + h) L2: sub $s0,$s1,$s2 #$s0 = (g - h) L3: add $s0,$s3,$s4 #$s0 = (i - j) Exit: 24 switch (k) { case 0: f = i + j; break; case 1: f = g + h; break; case 2: f = g h; break; case 3: f = I j; break; } Assume that the variables f through k are stored in the registers: $s0 to $s5. The register $t2 contains 4. What is the MIPS code? To write the MIPS Code for the above code, 2 additional MIPS instructions are introduced 1. Set it less than: slt $t0,$s3,$s4 # if ($s3<$s4) $t0=1; else $t0=0; 2. Jump register jr $s3 # jump to address contained in $s3 23 switch (k) { case 0: f = i + j; break case 1: f = g + h; break case 2: f = g h; break; case 3: f = i j; break; } f to k stored $s0 to $s5 $t2 = 4 $t4 contains address of an array, jumptable jumbtable[3] jumptable[2] jumptable[1] jumptable[0] Address of L3 Address of L2 Address of L1 Address of L0
7 Summary Name Example Comments 32 Registers Memory w/ 2 30 words $s0,$s1, $s7, $zero $t0,$t1, $t9 Memory[0], Memory[4], Memory[ ] $s0-$s7 are preserved across procedures, $t0-$t9 are not preserved Memory is accessed one word at a time Arithmetic Data Transfer Conditional branch Unconditional jump add add $s1,$s2,$s3 $s1 $s2+$s3 subtract sub $s1,$s2,$s3 $s1 $s2-$s3 load word lw $s1,100($s2) $s1 Mem[$s2+100] store word lw $s1,100($s2) Mem[$s2+100] $s1 branch on equal beq $s1,$s2,l if($s1==$s2) go to L branch not equal bne $s1,$s2,l if($s1!=$s2) go to L set on less than slt $s1,$s2,$s3 if($s2<$s3) $s1 = 1 else $s1 = 0 jump j 2500 go to (4 x 2500) Jump register jr $ra go to $ra 25
Reduced Instruction Set Computer (RISC)
Reduced Instruction Set Computer (RISC) Focuses on reducing the number and complexity of instructions of the ISA. RISC Goals RISC: Simplify ISA Simplify CPU Design Better CPU Performance Motivated by simplifying
More informationReduced Instruction Set Computer (RISC)
Reduced Instruction Set Computer (RISC) Reduced Instruction Set Computer (RISC) Focuses on reducing the number and complexity of instructions of the machine. Reduced number of cycles needed per instruction.
More informationInstructions: MIPS ISA. Chapter 2 Instructions: Language of the Computer 1
Instructions: MIPS ISA Chapter 2 Instructions: Language of the Computer 1 PH Chapter 2 Pt A Instructions: MIPS ISA Based on Text: Patterson Henessey Publisher: Morgan Kaufmann Edited by Y.K. Malaiya for
More informationCOMPSCI 313 S Computer Organization. 7 MIPS Instruction Set
COMPSCI 313 S2 2018 Computer Organization 7 MIPS Instruction Set Agenda & Reading MIPS instruction set MIPS I-format instructions MIPS R-format instructions 2 7.1 MIPS Instruction Set MIPS Instruction
More informationLecture 4: MIPS Instruction Set
Lecture 4: MIPS Instruction Set No class on Tuesday Today s topic: MIPS instructions Code examples 1 Instruction Set Understanding the language of the hardware is key to understanding the hardware/software
More information5/17/2012. Recap from Last Time. CSE 2021: Computer Organization. The RISC Philosophy. Levels of Programming. Stored Program Computers
CSE 2021: Computer Organization Recap from Last Time load from disk High-Level Program Lecture-2 Code Translation-1 Registers, Arithmetic, logical, jump, and branch instructions MIPS to machine language
More informationRecap from Last Time. CSE 2021: Computer Organization. Levels of Programming. The RISC Philosophy 5/19/2011
CSE 2021: Computer Organization Recap from Last Time load from disk High-Level Program Lecture-3 Code Translation-1 Registers, Arithmetic, logical, jump, and branch instructions MIPS to machine language
More informationChapter 2: Instructions:
Chapter 2: Instructions: Language of the Computer Computer Architecture CS-3511-2 1 Instructions: To command a computer s hardware you must speak it s language The computer s language is called instruction
More informationChapter 2. Instructions:
Chapter 2 1 Instructions: Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow Very restrictive e.g., MIPS Arithmetic Instructions We ll be working with
More informationMachine Language Instructions Introduction. Instructions Words of a language understood by machine. Instruction set Vocabulary of the machine
Machine Language Instructions Introduction Instructions Words of a language understood by machine Instruction set Vocabulary of the machine Current goal: to relate a high level language to instruction
More informationStored Program Concept. Instructions: Characteristics of Instruction Set. Architecture Specification. Example of multiple operands
Stored Program Concept Instructions: Instructions are bits Programs are stored in memory to be read or written just like data Processor Memory memory for data, programs, compilers, editors, etc. Fetch
More informationIntroduction to the MIPS. Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University
Introduction to the MIPS Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University Introduction to the MIPS The Microprocessor without Interlocked Pipeline Stages
More informationChapter 2. Computer Abstractions and Technology. Lesson 4: MIPS (cont )
Chapter 2 Computer Abstractions and Technology Lesson 4: MIPS (cont ) Logical Operations Instructions for bitwise manipulation Operation C Java MIPS Shift left >>> srl Bitwise
More informationECE232: Hardware Organization and Design. Computer Organization - Previously covered
ECE232: Hardware Organization and Design Part 6: MIPS Instructions II http://www.ecs.umass.edu/ece/ece232/ Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Computer Organization
More informationComputer Organization and Structure. Bing-Yu Chen National Taiwan University
Computer Organization and Structure Bing-Yu Chen National Taiwan University Instructions: Language of the Computer Operations and Operands of the Computer Hardware Signed and Unsigned Numbers Representing
More informationECE232: Hardware Organization and Design
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
More informationInstructions: Language of the Computer
CS359: Computer Architecture Instructions: Language of the Computer Yanyan Shen Department of Computer Science and Engineering 1 The Language a Computer Understands Word a computer understands: instruction
More informationComputer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: MIPS Instruction Set Architecture
Computer Science 324 Computer Architecture Mount Holyoke College Fall 2009 Topic Notes: MIPS Instruction Set Architecture vonneumann Architecture Modern computers use the vonneumann architecture. Idea:
More informationChapter 3 MIPS Assembly Language. Ó1998 Morgan Kaufmann Publishers 1
Chapter 3 MIPS Assembly Language Ó1998 Morgan Kaufmann Publishers 1 Instructions: Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow Very restrictive
More informationChapter 2A Instructions: Language of the Computer
Chapter 2A Instructions: Language of the Computer Copyright 2009 Elsevier, Inc. All rights reserved. Instruction Set The repertoire of instructions of a computer Different computers have different instruction
More informationAll instructions have 3 operands Operand order is fixed (destination first)
Instruction Set Architecture for MIPS Processors Overview Dr. Arjan Durresi Louisiana State University Baton Rouge, LA 70803 durresi@csc.lsu.edu These slides are available at: http://www.csc.lsu.edu/~durresi/_07/
More informationComputer Architecture
Computer Architecture Chapter 2 Instructions: Language of the Computer Fall 2005 Department of Computer Science Kent State University Assembly Language Encodes machine instructions using symbols and numbers
More informationLecture 5: Procedure Calls
Lecture 5: Procedure Calls Today s topics: Memory layout, numbers, control instructions Procedure calls 1 Memory Organization The space allocated on stack by a procedure is termed the activation record
More informationCS222: MIPS Instruction Set
CS222: MIPS Instruction Set Dr. A. Sahu Dept of Comp. Sc. & Engg. Indian Institute of Technology Guwahati 1 Outline Previous Introduction to MIPS Instruction Set MIPS Arithmetic's Register Vs Memory, Registers
More informationCMPE324 Computer Architecture Lecture 2
CMPE324 Computer Architecture Lecture 2.1 What is Computer Architecture? Software Hardware Application (Netscape) Operating System Compiler (Unix; Assembler Windows 9x) Processor Memory Datapath & Control
More informationELEC / Computer Architecture and Design Fall 2013 Instruction Set Architecture (Chapter 2)
ELEC 5200-001/6200-001 Computer Architecture and Design Fall 2013 Instruction Set Architecture (Chapter 2) Victor P. Nelson, Professor & Asst. Chair Vishwani D. Agrawal, James J. Danaher Professor Department
More informationChapter 3. Instructions:
Chapter 3 1 Instructions: Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow Very restrictive e.g., MIPS Arithmetic Instructions We ll be working with
More informationComputer Organization and Structure. Bing-Yu Chen National Taiwan University
Computer Organization and Structure Bing-Yu Chen National Taiwan University Instructions: Language of the Computer Operations and Operands of the Computer Hardware Signed and Unsigned Numbers Representing
More informationMIPS R-format Instructions. Representing Instructions. Hexadecimal. R-format Example. MIPS I-format Example. MIPS I-format Instructions
Representing Instructions Instructions are encoded in binary Called machine code MIPS instructions Encoded as 32-bit instruction words Small number of formats encoding operation code (opcode), register
More informationInstructions: MIPS arithmetic. MIPS arithmetic. Chapter 3 : MIPS Downloaded from:
Instructions: Chapter 3 : MIPS Downloaded from: http://www.cs.umr.edu/~bsiever/cs234/ Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow Very restrictive
More informationCISC 662 Graduate Computer Architecture. Lecture 4 - ISA
CISC 662 Graduate Computer Architecture Lecture 4 - ISA Michela Taufer http://www.cis.udel.edu/~taufer/courses Powerpoint Lecture Notes from John Hennessy and David Patterson s: Computer Architecture,
More informationMath 230 Assembly Programming (AKA Computer Organization) Spring 2008
Math 230 Assembly Programming (AKA Computer Organization) Spring 2008 MIPS Intro II Lect 10 Feb 15, 2008 Adapted from slides developed for: Mary J. Irwin PSU CSE331 Dave Patterson s UCB CS152 M230 L10.1
More informationECE369. Chapter 2 ECE369
Chapter 2 1 Instruction Set Architecture A very important abstraction interface between hardware and low-level software standardizes instructions, machine language bit patterns, etc. advantage: different
More informationCISC 662 Graduate Computer Architecture. Lecture 4 - ISA MIPS ISA. In a CPU. (vonneumann) Processor Organization
CISC 662 Graduate Computer Architecture Lecture 4 - ISA MIPS ISA Michela Taufer http://www.cis.udel.edu/~taufer/courses Powerpoint Lecture Notes from John Hennessy and David Patterson s: Computer Architecture,
More informationAnnouncements HW1 is due on this Friday (Sept 12th) Appendix A is very helpful to HW1. Check out system calls
Announcements HW1 is due on this Friday (Sept 12 th ) Appendix A is very helpful to HW1. Check out system calls on Page A-48. Ask TA (Liquan chen: liquan@ece.rutgers.edu) about homework related questions.
More informationCS31001 COMPUTER ORGANIZATION AND ARCHITECTURE. Debdeep Mukhopadhyay, CSE, IIT Kharagpur. Instructions and Addressing
CS31001 COMPUTER ORGANIZATION AND ARCHITECTURE Debdeep Mukhopadhyay, CSE, IIT Kharagpur Instructions and Addressing 1 ISA vs. Microarchitecture An ISA or Instruction Set Architecture describes the aspects
More informationChapter 2. Instructions: Language of the Computer. Adapted by Paulo Lopes
Chapter 2 Instructions: Language of the Computer Adapted by Paulo Lopes Instruction Set The repertoire of instructions of a computer Different computers have different instruction sets But with many aspects
More informationCourse Administration
Fall 2017 EE 3613: Computer Organization Chapter 2: Instruction Set Architecture 2/4 Avinash Kodi Department of Electrical Engineering & Computer Science Ohio University, Athens, Ohio 45701 E-mail: kodi@ohio.edu
More informationUnsigned Binary Integers
Unsigned Binary Integers Given an n-bit number x x n 1 n 2 1 0 n 12 xn 22 x12 x02 Range: 0 to +2 n 1 Example 2.4 Signed and Unsigned Numbers 0000 0000 0000 0000 0000 0000 0000 1011 2 = 0 + + 1 2 3 + 0
More informationUnsigned Binary Integers
Unsigned Binary Integers Given an n-bit number x x n 1 n 2 1 0 n 12 xn 22 x12 x02 Range: 0 to +2 n 1 Example 2.4 Signed and Unsigned Numbers 0000 0000 0000 0000 0000 0000 0000 1011 2 = 0 + + 1 2 3 + 0
More informationECE 331 Hardware Organization and Design. Professor Jay Taneja UMass ECE - Discussion 3 2/8/2018
ECE 331 Hardware Organization and Design Professor Jay Taneja UMass ECE - jtaneja@umass.edu Discussion 3 2/8/2018 Study Jams Leader: Chris Bartoli Tuesday 5:30-6:45pm Elab 325 Wednesday 8:30-9:45pm Elab
More informationChapter 2. Instructions: Language of the Computer. HW#1: 1.3 all, 1.4 all, 1.6.1, , , , , and Due date: one week.
Chapter 2 Instructions: Language of the Computer HW#1: 1.3 all, 1.4 all, 1.6.1, 1.14.4, 1.14.5, 1.14.6, 1.15.1, and 1.15.4 Due date: one week. Practice: 1.5 all, 1.6 all, 1.10 all, 1.11 all, 1.14 all,
More informationStored Program Concept. Instructions: Characteristics of Instruction Set. Architecture Specification. Example of multiple operands
Stored Program Concept nstructions: nstructions are bits Programs are stored in memory to be read or written just like data Processor Memory memory for data, programs, compilers, editors, etc. Fetch &
More informationCS3350B Computer Architecture MIPS Introduction
CS3350B Computer Architecture MIPS Introduction Marc Moreno Maza http://www.csd.uwo.ca/~moreno/cs3350_moreno/index.html Department of Computer Science University of Western Ontario, Canada Thursday January
More informationTopic Notes: MIPS Instruction Set Architecture
Computer Science 220 Assembly Language & Comp. Architecture Siena College Fall 2011 Topic Notes: MIPS Instruction Set Architecture vonneumann Architecture Modern computers use the vonneumann architecture.
More informationInstruction Set Architecture
Computer Architecture Instruction Set Architecture Lynn Choi Korea University Machine Language Programming language High-level programming languages Procedural languages: C, PASCAL, FORTRAN Object-oriented
More informationRui Wang, Assistant professor Dept. of Information and Communication Tongji University.
Instructions: ti Language of the Computer Rui Wang, Assistant professor Dept. of Information and Communication Tongji University it Email: ruiwang@tongji.edu.cn Computer Hierarchy Levels Language understood
More informationComputer Organization MIPS ISA
CPE 335 Computer Organization MIPS ISA Dr. Iyad Jafar Adapted from Dr. Gheith Abandah Slides http://www.abandah.com/gheith/courses/cpe335_s08/index.html CPE 232 MIPS ISA 1 (vonneumann) Processor Organization
More informationChapter 2. Instruction Set Architecture (ISA)
Chapter 2 Instruction Set Architecture (ISA) MIPS arithmetic Design Principle: simplicity favors regularity. Why? Of course this complicates some things... C code: A = B + C + D; E = F - A; MIPS code:
More informationToday s topics. MIPS operations and operands. MIPS arithmetic. CS/COE1541: Introduction to Computer Architecture. A Review of MIPS ISA.
Today s topics CS/COE1541: Introduction to Computer Architecture MIPS operations and operands MIPS registers Memory view Instruction encoding A Review of MIPS ISA Sangyeun Cho Arithmetic operations Logic
More informationControl Instructions. Computer Organization Architectures for Embedded Computing. Thursday, 26 September Summary
Control Instructions Computer Organization Architectures for Embedded Computing Thursday, 26 September 2013 Many slides adapted from: Computer Organization and Design, Patterson & Hennessy 4th Edition,
More informationControl Instructions
Control Instructions Tuesday 22 September 15 Many slides adapted from: and Design, Patterson & Hennessy 5th Edition, 2014, MK and from Prof. Mary Jane Irwin, PSU Summary Previous Class Instruction Set
More informationCENG3420 Lecture 03 Review
CENG3420 Lecture 03 Review Bei Yu byu@cse.cuhk.edu.hk 2017 Spring 1 / 38 CISC vs. RISC Complex Instruction Set Computer (CISC) Lots of instructions of variable size, very memory optimal, typically less
More informationCS3350B Computer Architecture
CS3350B Computer Architecture Winter 2015 Lecture 4.1: MIPS ISA: Introduction Marc Moreno Maza www.csd.uwo.ca/courses/cs3350b [Adapted d from lectures on Computer Organization and Design, Patterson & Hennessy,
More informationCPSC 330 Computer Organization
CPSC 330 Computer Organization Chapter 2-II Instructions: Language of the computer MIPS Instructions - Review Instruction Meaning add $s1,$s2,$s3 $s1 = $s2 + $s3 sub $s1,$s2,$s3 $s1 = $s2 $s3 addi $s1,$s1,4
More informationInstruction Set Design and Architecture
Instruction Set Design and Architecture COE608: Computer Organization and Architecture Dr. Gul N. Khan http://www.ee.ryerson.ca/~gnkhan Electrical and Computer Engineering Ryerson University Overview Computer
More informationCENG3420 L03: Instruction Set Architecture
CENG3420 L03: Instruction Set Architecture Bei Yu byu@cse.cuhk.edu.hk (Latest update: January 31, 2018) Spring 2018 1 / 49 Overview Introduction Arithmetic & Logical Instructions Data Transfer Instructions
More informationCS/COE1541: Introduction to Computer Architecture
CS/COE1541: Introduction to Computer Architecture Dept. of Computer Science University of Pittsburgh http://www.cs.pitt.edu/~melhem/courses/1541p/index.html 1 Computer Architecture? Application pull Operating
More informationComputer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: MIPS Instruction Set Architecture
Computer Science 324 Computer Architecture Mount Holyoke College Fall 2007 Topic Notes: MIPS Instruction Set Architecture vonneumann Architecture Modern computers use the vonneumann architecture. Idea:
More informationI-Format Instructions (3/4) Define fields of the following number of bits each: = 32 bits
CS61C L10 MIPS Instruction Representation II (1) inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #10 Instruction Representation II 2007-7-8 Review There are register calling conventions!
More informationChapter 1. Computer Abstractions and Technology. Lesson 3: Understanding Performance
Chapter 1 Computer Abstractions and Technology Lesson 3: Understanding Performance Manufacturing ICs 1.7 Real Stuff: The AMD Opteron X4 Yield: proportion of working dies per wafer Chapter 1 Computer Abstractions
More informationLecture 2. Instructions: Language of the Computer (Chapter 2 of the textbook)
Lecture 2 Instructions: Language of the Computer (Chapter 2 of the textbook) Instructions: tell computers what to do Chapter 2 Instructions: Language of the Computer 2 Introduction Chapter 2.1 Chapter
More informationMIPS%Assembly% E155%
MIPS%Assembly% E155% Outline MIPS Architecture ISA Instruction types Machine codes Procedure call Stack 2 The MIPS Register Set Name Register Number Usage $0 0 the constant value 0 $at 1 assembler temporary
More informationBranch Addressing. Jump Addressing. Target Addressing Example. The University of Adelaide, School of Computer Science 28 September 2015
Branch Addressing Branch instructions specify Opcode, two registers, target address Most branch targets are near branch Forward or backward op rs rt constant or address 6 bits 5 bits 5 bits 16 bits PC-relative
More informationCOMPUTER ORGANIZATION AND DESIGN
COMPUTER ORGANIZATION AND DESIGN 5 th The Hardware/Software Interface Edition Chapter 2 Instructions: Language of the Computer 2.1 Introduction Instruction Set The repertoire of instructions of a computer
More informationChapter 4. The Processor. Computer Architecture and IC Design Lab
Chapter 4 The Processor Introduction CPU performance factors CPI Clock Cycle Time Instruction count Determined by ISA and compiler CPI and Cycle time Determined by CPU hardware We will examine two MIPS
More informationCS 4200/5200 Computer Architecture I
CS 4200/5200 Computer Architecture I MIPS Instruction Set Architecture Dr. Xiaobo Zhou Department of Computer Science CS420/520 Lec3.1 UC. Colorado Springs Adapted from UCB97 & UCB03 Review: Organizational
More informationENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design
ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design Professor Sherief Reda http://scale.engin.brown.edu School of Engineering Brown University Spring 2014 Sources: Computer
More informationComputer Organization and Design
Computer Organization and Design The Hardware/Software Interface Chapter 2 - Introductions: Language of the Computer Dr. Feng Li fli@sdu.edu.cn https://funglee.github.io 1 Contents of Chapter 2 l 2.1 Introduction
More informationCS61C Constants and Making Decisions in C/Assembly Language. Lecture 3. January 27, 1999 Dave Patterson (http.cs.berkeley.
CS61C Constants and Making Decisions in C/Assembly Language Lecture 3 January 27, 1999 Dave Patterson (http.cs.berkeley.edu/~patterson) www-inst.eecs.berkeley.edu/~cs61c/schedule.html cs 61C L3 Decisions.1
More informationCS 61C: Great Ideas in Computer Architecture. MIPS Instruction Formats
CS 61C: Great Ideas in Computer Architecture MIPS Instruction Formats Instructor: Justin Hsia 6/27/2012 Summer 2012 Lecture #7 1 Review of Last Lecture New registers: $a0-$a3, $v0-$v1, $ra, $sp Also: $at,
More informationChapter 2. Instructions: Language of the Computer
Chapter 2 Instructions: Language of the Computer Instruction Set The repertoire of instructions of a computer Different computers have different instruction sets But with many aspects in common Early computers
More informationEEC 581 Computer Architecture Lecture 1 Review MIPS
EEC 581 Computer Architecture Lecture 1 Review MIPS 1 Supercomputing: Suddenly Fancy 2 1 Instructions: Language of the Machine More primitive than higher level languages e.g., no sophisticated control
More informationEN164: Design of Computing Systems Topic 03: Instruction Set Architecture Design
EN164: Design of Computing Systems Topic 03: Instruction Set Architecture Design Professor Sherief Reda http://scale.engin.brown.edu Electrical Sciences and Computer Engineering School of Engineering Brown
More informationChapter 2. lw $s1,100($s2) $s1 = Memory[$s2+100] sw $s1,100($s2) Memory[$s2+100] = $s1
Chapter 2 1 MIPS Instructions Instruction Meaning add $s1,$s2,$s3 $s1 = $s2 + $s3 sub $s1,$s2,$s3 $s1 = $s2 $s3 addi $s1,$s2,4 $s1 = $s2 + 4 ori $s1,$s2,4 $s2 = $s2 4 lw $s1,100($s2) $s1 = Memory[$s2+100]
More informationMACHINE LANGUAGE. To work with the machine, we need a translator.
LECTURE 2 Assembly MACHINE LANGUAGE As humans, communicating with a machine is a tedious task. We can t, for example, just say add this number and that number and store the result here. Computers have
More informationInstructions: Language of the Computer
CS359: Computer Architecture Instructions: Language of the Computer Yanyan Shen Department of Computer Science and Engineering 1 The Language a Computer Understands Word a computer understands: instruction
More informationECE 154A Introduction to. Fall 2012
ECE 154A Introduction to Computer Architecture Fall 2012 Dmitri Strukov Lecture 4: Arithmetic and Data Transfer Instructions Agenda Review of last lecture Logic and shift instructions Load/store instructionsi
More informationcomp 180 Lecture 10 Outline of Lecture Procedure calls Saving and restoring registers Summary of MIPS instructions
Outline of Lecture Procedure calls Saving and restoring registers Summary of MIPS instructions Procedure Calls A procedure of a subroutine is like an agent which needs certain information to perform a
More informationCS3350B Computer Architecture MIPS Instruction Representation
CS3350B Computer Architecture MIPS Instruction Representation Marc Moreno Maza http://www.csd.uwo.ca/~moreno/cs3350_moreno/index.html Department of Computer Science University of Western Ontario, Canada
More informationCS61C : Machine Structures
inst.eecs.berkeley.edu/~cs61c/su06 CS61C : Machine Structures Lecture #8: MIPS Memory & Decisions 2006-07-10 CS 61C L08 MIPS Memory (1) Andy Carle Review In MIPS Assembly Language: Registers replace C
More informationDo-While Example. In C++ In assembly language. do { z--; while (a == b); z = b; loop: addi $s2, $s2, -1 beq $s0, $s1, loop or $s2, $s1, $zero
Do-While Example In C++ do { z--; while (a == b); z = b; In assembly language loop: addi $s2, $s2, -1 beq $s0, $s1, loop or $s2, $s1, $zero 25 Comparisons Set on less than (slt) compares its source registers
More informationComputer Organization MIPS Architecture. Department of Computer Science Missouri University of Science & Technology
Computer Organization MIPS Architecture Department of Computer Science Missouri University of Science & Technology hurson@mst.edu Computer Organization Note, this unit will be covered in three lectures.
More informationGrading: 3 pts each part. If answer is correct but uses more instructions, 1 pt off. Wrong answer 3pts off.
Department of Electrical and Computer Engineering University of Wisconsin Madison ECE 552 Introductions to Computer Architecture Homework #2 (Suggested Solution) 1. (10 points) MIPS and C program translations
More informationAssembler. Lecture 8 CS301
Assembler Lecture 8 CS301 Discussion Given the following function header, int foo(int a, int b); what will be on the stack before any of the calculations in foo are performed? Assume foo() calls some other
More informationAssembly Language Programming. CPSC 252 Computer Organization Ellen Walker, Hiram College
Assembly Language Programming CPSC 252 Computer Organization Ellen Walker, Hiram College Instruction Set Design Complex and powerful enough to enable any computation Simplicity of equipment MIPS Microprocessor
More information101 Assembly. ENGR 3410 Computer Architecture Mark L. Chang Fall 2009
101 Assembly ENGR 3410 Computer Architecture Mark L. Chang Fall 2009 What is assembly? 79 Why are we learning assembly now? 80 Assembly Language Readings: Chapter 2 (2.1-2.6, 2.8, 2.9, 2.13, 2.15), Appendix
More informationCSE 141 Computer Architecture Spring Lecture 3 Instruction Set Architecute. Course Schedule. Announcements
CSE141: Introduction to Computer Architecture CSE 141 Computer Architecture Spring 2005 Lecture 3 Instruction Set Architecute Pramod V. Argade April 4, 2005 Instructor: TAs: Pramod V. Argade (p2argade@cs.ucsd.edu)
More informationComputer Architecture
CS3350B Computer Architecture Winter 2015 Lecture 4.2: MIPS ISA -- Instruction Representation Marc Moreno Maza www.csd.uwo.ca/courses/cs3350b [Adapted from lectures on Computer Organization and Design,
More informationCS 110 Computer Architecture Lecture 6: More MIPS, MIPS Functions
CS 110 Computer Architecture Lecture 6: More MIPS, MIPS Functions Instructor: Sören Schwertfeger http://shtech.org/courses/ca/ School of Information Science and Technology SIST ShanghaiTech University
More informationENE 334 Microprocessors
ENE 334 Microprocessors Lecture 2: Instructions Week #02 : Dejwoot KHAWPARISUTH Adapted from Computer Organization and Design, 3 th & 4 th Edition, Patterson & Hennessy, 2005/2008, Elsevier (MK) and Lecture
More informationEN164: Design of Computing Systems Lecture 09: Processor / ISA 2
EN164: Design of Computing Systems Lecture 09: Processor / ISA 2 Professor Sherief Reda http://scale.engin.brown.edu Electrical Sciences and Computer Engineering School of Engineering Brown University
More informationCharacter Is a byte quantity (00~FF or 0~255) ASCII (American Standard Code for Information Interchange) Page 91, Fig. 2.21
2.9 Communication with People: Byte Data & Constants Character Is a byte quantity (00~FF or 0~255) ASCII (American Standard Code for Information Interchange) Page 91, Fig. 2.21 32: space 33:! 34: 35: #...
More informationInstructions: Language of the Computer
Instructions: Language of the Computer Tuesday 22 September 15 Many slides adapted from: and Design, Patterson & Hennessy 5th Edition, 2014, MK and from Prof. Mary Jane Irwin, PSU Summary Previous Class
More informationComputer Architecture. Lecture 2 : Instructions
Computer Architecture Lecture 2 : Instructions 1 Components of a Computer Hierarchical Layers of Program Code 3 Instruction Set The repertoire of instructions of a computer 2.1 Intr roduction Different
More informationChapter 2. Instruction Set. The MIPS Instruction Set. Arithmetic Operations. Instructions: Language of the Computer
COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition Chapter 2 Instructions: Language of the Computer
More informationInstruction Set Architecture part 1 (Introduction) Mehran Rezaei
Instruction Set Architecture part 1 (Introduction) Mehran Rezaei Overview Last Lecture s Review Execution Cycle Levels of Computer Languages Stored Program Computer/Instruction Execution Cycle SPIM, a
More informationOperations, Operands, and Instructions
Operations, Operands, and Instructions Tom Kelliher, CS 220 Sept. 12, 2011 1 Administrivia Announcements Assignment Read 2.6 2.7. From Last Time Macro-architectural trends; IC fab. Outline 1. Introduction.
More informationCSEE 3827: Fundamentals of Computer Systems
CSEE 3827: Fundamentals of Computer Systems Lecture 15 April 1, 2009 martha@cs.columbia.edu and the rest of the semester Source code (e.g., *.java, *.c) (software) Compiler MIPS instruction set architecture
More informationMIPS Instruction Set Architecture (2)
MIPS Instruction Set Architecture (2) Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu EEE3050: Theory on Computer Architectures, Spring 2017, Jinkyu
More information