Computer Architecture & Operations I

Slides:



Advertisements
Similar presentations
CENG 311 Decisions in C/Assembly Language
Advertisements

Goal: Write Programs in Assembly
4.
Lecture 5: MIPS Instruction Set
MIPS assembly. Review  Lat lecture, we learnt  addi,  and, andi, or, ori, xor, xori, nor,  beq, j, bne  An array is stored sequentially in the memory.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /15/2013 Lecture 11: MIPS-Conditional Instructions Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER.
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.
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.
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.
Data Transfer & Decisions I (1) Fall 2005 Lecture 3: MIPS Assembly language Decisions I.
MIPS Instruction Set Advantages
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.
1 Branches and Procedure Calls Lecture 14 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.
11/02/2009CA&O Lecture 03 by Engr. Umbreen Sabir Computer Architecture & Organization Instructions: Language of Computer Engr. Umbreen Sabir Computer Engineering.
Lecture 4: MIPS Instruction Set
IFT 201: Unit 1 Lecture 1.3: Processor Architecture-3
MIPS coding. Review Shifting – Shift Left Logical (sll) – Shift Right Logical (srl) – Moves all of the bits to the left/right and fills in gap with 0’s.
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.
9/29: Lecture Topics Conditional branch instructions
Chapter 2 CSF 2009 The MIPS Assembly Language. Stored Program Computers Instructions represented in binary, just like data Instructions and data stored.
MS108 Computer System I Lecture 3 ISA Prof. Xiaoyao Liang 2015/3/13 1.
Computer Organization Instructions Language of The Computer (MIPS) 2.
Computer Organization CS224 Fall 2012 Lessons 7 and 8.
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.
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.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Lecture 17: 10/31/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Computer Architecture & Operations I
MIPS Assembly Language Programming
Computer Architecture Instruction Set Architecture
MIPS Instruction Set Advantages
CS2100 Computer Organisation
COMPUTER ARCHITECTURE & OPERATIONS I
Computer Architecture Instruction Set Architecture
MIPS Coding Continued.
Lecture 4: MIPS Instruction Set
Decision Making.
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,
Computer Architecture & Operations I
Instructions for Making Decisions
CS170 Computer Organization and Architecture I
The University of Adelaide, School of Computer Science
MIPS coding.
Pick up the handout on your way in!!
Lecture 4: MIPS Instruction Set
Logical and Decision Operations
MIPS coding.
Chapter 2 Instructions: Language of the Computer part 2
MIPS Coding.
The University of Adelaide, School of Computer Science
3.
COMS 361 Computer Organization
COMS 361 Computer Organization
MIPS Assembly.
MIPS Coding Continued.
MIPS coding.
MIPS assembly.
Computer Architecture
9/27: Lecture Topics Memory Data transfer instructions
MIPS instructions.
Conditional Branching (beq)
Presentation transcript:

Computer Architecture & Operations I Instructor: Ryan Florin

Instructions for Making Decisions High-level programming language C/C++: if … else … (conditional) goto (unconditional) for, while, until (loops) Assembly Languages MIPS: beq (branch if equal) bne (branch if not equal) j (unconditional jump)

Conditional Operations The University of Adelaide, School of Computer Science 21 July 2018 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 Chapter 2 — Instructions: Language of the Computer

Compiling If Statements The University of Adelaide, School of Computer Science 21 July 2018 Compiling If Statements C code: if (i==j) f = g+h; else f = g-h; Chapter 2 — Instructions: Language of the Computer

Compiling If Statements The University of Adelaide, School of Computer Science 21 July 2018 Compiling If Statements C code: if (i==j) f = g+h; else f = g-h; f ($s0), g ($s1), h($s2), i($s3), j($s4) Compiled MIPS code: bne $s3, $s4, Else add $s0, $s1, $s2 j Exit Else: sub $s0, $s1, $s2 Exit: … Assembler calculates addresses Chapter 2 — Instructions: Language of the Computer

Compiling Loop Statements The University of Adelaide, School of Computer Science 21 July 2018 Compiling Loop Statements C code: while (save[i] == k) i = i+1; i in $s3, k in $s5, address of save in $s6 Flowchart? Chapter 2 — Instructions: Language of the Computer

Compiling Loop Statements The University of Adelaide, School of Computer Science 21 July 2018 Compiling Loop Statements C code: while (save[i] == k) i = i+1; i in $s3, k in $s5, address of save in $s6 Compiled MIPS code: Loop: sll $t1, $s3, 2 add $t1, $t1, $s6 lw $t0, 0($t1) bne $t0, $s5, Exit addi $s3, $s3, 1 j Loop Exit: … Chapter 2 — Instructions: Language of the Computer

The University of Adelaide, School of Computer Science 21 July 2018 More Examples C code: for (i=1; i<=5; i++) count++; How to initialize a variable? addi $t0, $zero, 0 # $t0 = 0 addi $t1, $zero, 10 # $t1 = 10 Chapter 2 — Instructions: Language of the Computer

The University of Adelaide, School of Computer Science 21 July 2018 More Examples C code: for (i=1; i<=5; i++) sum += A[i]; What assumptions need to be made? What is the address of array A? Should sum be initialized? Chapter 2 — Instructions: Language of the Computer

Summary Conditional Instructions Converting a C Program to MIPS beq bne j Converting a C Program to MIPS