11/02/2009CA&O Lecture 03 by Engr. Umbreen Sabir Computer Architecture & Organization Instructions: Language of Computer Engr. Umbreen Sabir Computer Engineering.

Slides:



Advertisements
Similar presentations
1 Lecture 3: MIPS Instruction Set Today’s topic:  More MIPS instructions  Procedure call/return Reminder: Assignment 1 is on the class web-page (due.
Advertisements

Goal: Write Programs in Assembly
Review of the MIPS Instruction Set Architecture. RISC Instruction Set Basics All operations on data apply to data in registers and typically change the.
Lecture 5: MIPS Instruction Set
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /15/2013 Lecture 11: MIPS-Conditional Instructions Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER.
©UCB CS 161 Lecture 4 Prof. L.N. Bhuyan
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 5: Data Transfer Instructions / Control Flow Instructions Partially adapted from Computer.
Lecture 6: MIPS Instruction Set Today’s topic –Control instructions –Procedure call/return 1.
CS1104 – Computer Organization PART 2: Computer Architecture Lecture 5 MIPS ISA & Assembly Language Programming.
ELEN 468 Advanced Logic Design
CMPT 334 Computer Organization Chapter 2 Instructions: Language of the Computer [Adapted from Computer Organization and Design 5 th Edition, Patterson.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /17/2013 Lecture 12: Procedures Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.
Apr. 12, 2000Systems Architecture I1 Systems Architecture I (CS ) Lecture 6: Branching and Procedures in MIPS* Jeremy R. Johnson Wed. Apr. 12, 2000.
Comp Sci instruction encoding 1 Instruction Encoding MIPS machine language Binary encoding of instructions MIPS instruction = 32 bits Three instruction.
1 Warning! Unlike the previous lessons, for today's lesson you will have to listen, think and even understand (for the exam, of course). Individuals with.
ENEE350 Spring07 1 Ankur Srivastava University of Maryland, College Park Adapted from Computer Organization and Design, Patterson & Hennessy, © 2005.”
S. Barua – CPSC 440 CHAPTER 2 INSTRUCTIONS: LANGUAGE OF THE COMPUTER Goals – To get familiar with.
1 Lecture 2: MIPS Instruction Set Today’s topic:  MIPS instructions Reminder: sign up for the mailing list cs3810 Reminder: set up your CADE accounts.
RISC Concepts, MIPS ISA and the Mini–MIPS project
Lecture 5 Sept 14 Goals: Chapter 2 continued MIPS assembly language instruction formats translating c into MIPS - examples.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Hao Ji.
ECE 232 L5 Assembl.1 Adapted from Patterson 97 ©UCBCopyright 1998 Morgan Kaufmann Publishers ECE 232 Hardware Organization and Design Lecture 5 MIPS Assembly.
Feb 18, 2009 Lecture 4-1 instruction set architecture (Part II of [Parhami]) MIPS assembly language instructions MIPS assembly programming.
CHAPTER 2 ISA Instructions (logical + procedure call)
13/02/2009CA&O Lecture 04 by Engr. Umbreen Sabir Computer Architecture & Organization Instructions: Language of Computer Engr. Umbreen Sabir Computer Engineering.
Lecture 8. MIPS Instructions #3 – Branch Instructions #1 Prof. Taeweon Suh Computer Science Education Korea University 2010 R&E Computer System Education.
Lecture 15: 10/24/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer Science York University Handout # 3: MIPS Instruction Set I Topics: 1.
6.S078 - Computer Architecture: A Constructive Approach Introduction to SMIPS Li-Shiuan Peh Computer Science & Artificial Intelligence Lab. Massachusetts.
April 23, 2001Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Assemblers, Linkers, and Loaders * Jeremy R. Johnson Mon. April 23,
Lecture 4: MIPS Instruction Set
Computer Architecture CSE 3322 Lecture 4 crystal.uta.edu/~jpatters/cse3322 Assignments due 9/15: 3.7, 3.9, 3.11.
Computer Organization & Programming Chapter 6 Single Datapath CPU Architecture.
Chapter 2 Decision-Making Instructions (Instructions: Language of the Computer Part V)
Computer Architecture CSE 3322 Lecture 3 Assignment: 2.4.1, 2.4.4, 2.6.1, , Due 2/3/09 Read 2.8.
Chapter 2 CSF 2009 The MIPS Assembly Language. Stored Program Computers Instructions represented in binary, just like data Instructions and data stored.
Computer Organization Instructions Language of The Computer (MIPS) 2.
Computer Organization CS224 Fall 2012 Lessons 7 and 8.
EET 4250 Instruction Representation & Formats Acknowledgements: Some slides and lecture notes for this course adapted from Prof. Mary Jane Penn.
Computer Architecture CSE 3322 Lecture 4 Assignment: 2.4.1, 2.4.4, 2.6.1, , Due 2/10/09
Chapter 2 — Instructions: Language of the Computer — 1 Conditional Operations Branch to a labeled instruction if a condition is true – Otherwise, continue.
CDA 3101 Spring 2016 Introduction to Computer Organization
Computer Organization Instructions Language of The Computer (MIPS) 2.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 11 Conditional Operations.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 12 Procedure Calling.
CMPUT Computer Organization and Architecture I1 CMPUT229 - Fall 2003 Topic3: Instructions, The Language of the Machine José Nelson Amaral.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Computer Architecture & Operations I
Computer Architecture Instruction Set Architecture
MIPS Instruction Set Advantages
Lecture 4: MIPS Instruction Set
ELEN 468 Advanced Logic Design
Computer Architecture & Operations I
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
Procedures (Functions)
Conditional Branches What distinguishes a computer from a simple calculator is its ability to make decisions Decisions are made using the if statement,
CS170 Computer Organization and Architecture I
The University of Adelaide, School of Computer Science
Instructions - Type and Format
Lecture 4: MIPS Instruction Set
ECE232: Hardware Organization and Design
Lecture 5: Procedure Calls
Logical and Decision Operations
Chapter 2 Instructions: Language of the Computer part 2
The University of Adelaide, School of Computer Science
Part II Instruction-Set Architecture
3.
COMS 361 Computer Organization
Systems Architecture I
Computer Architecture
Presentation transcript:

11/02/2009CA&O Lecture 03 by Engr. Umbreen Sabir Computer Architecture & Organization Instructions: Language of Computer Engr. Umbreen Sabir Computer Engineering Department, University of Engg. & Technology Taxila. 1

Instructions for Making Decisions Distinguishes computer from simple calculator. – Decision making Instructions are if with goto and label. MIPS decision making statements are: – Branch if equal-> beq register1, register2, L1 Go to label L1, if register1==register2 – Branch not equal-> bne register1, register2, L1 Go to label L1, if register1!=register2 These two statements are traditionally called Conditional Branches. 11/02/ CA&O Lecture 03 by Engr. Umbreen Sabir

MIPS Control Flow Instructions MIPS conditional branch instructions: bne $s0, $s1, Lbl#go to Lbl if $s0  $s1 beq $s0, $s1, Lbl#go to Lbl if $s0=$s1  Ex: if (i==j) h = i + j; bne $s0, $s1, Lbl1 add $s3, $s0, $s1 Lbl1:… 11/02/ CA&O Lecture 03 by Engr. Umbreen Sabir

MIPS Control Flow Instructions Instruction Format (I format): How is the branch destination address specified? Keep it pending till next chapter…. 11/02/ CA&O Lecture 03 by Engr. Umbreen Sabir op rs rt 16 bit offset

Compiling if-then-else into Conditional Branches: In the code below f, g, h, I and j are in registers $s0 through $s4. C code is – if ( i==j ) f= g + h; else f=g-h; Its assembly notation is: – Bne $s3, $s4, Else # go to Else if I != j – add $s0, $s1, $s2 # f= g + h (skipped if i != j). – j Exit # go to Exit. – Else:sub $s0, $s1, #s2 # f= g – h (skipped if i == j). 11/02/ CA&O Lecture 03 by Engr. Umbreen Sabir

Loops Decisions are also important for iterating a computation. – Found in loops. – Refer to next slide for an example. 11/02/2009CA&O Lecture 03 by Engr. Umbreen Sabir 6

Example # 1 C statements are: – While ( save[i] ==k) – i += 1; Assume i and k are in $s3 and $s5 and base of save is in $6. We must multiply i by 4 due to byte addressing problem. We use shift left logical since shifting left by 2 bits multiply by 4. 11/02/ CA&O Lecture 03 by Engr. Umbreen Sabir

Example # 1 cont. Assembly code will be: – Loop:sll $t1, $s3, 2 # Temp reg $t1 = 4 * i – Add $t1, $t1, $s6 # $t1= address of save[i] – Lw $t0, 0( $t1) # Temp reg $t0 = save[i] – Bne $t0, $s5, Exit # go to Exit if save[i] != k – Add $s3, $s3, 1 # i = i + 1; – J Loop # go to Loop – Exit: 11/02/ CA&O Lecture 03 by Engr. Umbreen Sabir

Basic Block A sequence of instructions without branches, except possibly at the end, and without branch targets or branch labels, except possibly at the beginning. One of the early phases of compilation is breaking the program into basic blocks. 11/02/ CA&O Lecture 03 by Engr. Umbreen Sabir

More Branch Instructions We have beq, bne, but what about other kinds of branches (e.g., branch-if-less-than)? For this, we need yet another instruction, slt. Set on less than instruction: slt $t0,$s0,$s1 # if $s0 < $s1 then # $t0 = 1else # $t0 = 0 Instruction format (R format): 11/02/ CA&O Lecture 03 by Engr. Umbreen Sabir op rs rt rd funct

More Branch Instructions cont. 11/02/2009CA&O Lecture 03 by Engr. Umbreen Sabir 11 Constant operands are also used in comparisons. Register $zero always has 0, we can compare to zero. To compare to other values, instruction is: Set on less than immediate: slti $t0,$s2,10 # $t0 = 1 if $s2< 10 MIPS doesn’t include branch on less than because it is too complicated. Either it would stretch the clock cycle time or it would take extra clock cycles/instruction.

More Branch Instructions cont. Can use slt, beq, bne, and the fixed value of 0 in register $zero to create all relative conditions. – less than blt $s1, $s2, Label – less than or equal to ble $s1, $s2, Label – greater than bgt $s1, $s2, Label – great than or equal to bge $s1, $s2, Label 11/02/ CA&O Lecture 03 by Engr. Umbreen Sabir slt $at, $s1, $s2#$at set to 1 if bne $at, $zero, Label# $s1 < $s2

Case/switch Statement Case/switch can be implemented through a sequence of conditional tests. More effectively done by jump address table. For this MIPS include a jump register instruction (jr), meaning an unconditional jump to the address specified in a register. 11/02/ CA&O Lecture 03 by Engr. Umbreen Sabir

Case/switch Statement 11/02/ CA&O Lecture 03 by Engr. Umbreen Sabir MIPS also has an unconditional branch instruction or jump instruction: j label#go to label.  Instruction Format (J Format): op 26-bit address

Supporting Procedures in Computer Hardware Procedure: A stored subroutine that performs a specific task based on the parameters with which it is provided. Procedure execution step – Place Parameters. – Transfer control to the procedure. – Acquire storage resources – Perform desired task. – Place result value. – Return control back. 11/02/2009CA&O Lecture 03 by Engr. Umbreen Sabir 15

Supporting Procedures in Computer Hardware cont. MIPS register conventions for procedures: – $a0 - $a3: argument registers – $v0 - $v1: two registers to return values. – $ra – return address register MIPS instruction for procedures is jump and link instruction (jal). – It jumps to an address and simultaneously saves the address of following instruction in return register $ra. 11/02/ CA&O Lecture 03 by Engr. Umbreen Sabir

Instructions for Accessing Procedures MIPS procedure call instruction: jal ProcedureAddress #jump n link Machine format (J format): Then can do procedure return with a jr$ra#return Instruction format (R format): 11/02/ CA&O Lecture 03 by Engr. Umbreen Sabir op rs funct op 26 bit address

Next Lecture and Reminders Next lecture – MIPS ISA Assignment Due – 13 Feb /02/ CA&O Lecture 03 by Engr. Umbreen Sabir

END OF LECTURE 3 11/02/2009CA&O Lecture 03 by Engr. Umbreen Sabir 19