MIPS assembly. Computer  What’s in a computer?  Processor, memory, I/O devices (keyboard, mouse, LCD, video camera, speaker), disk, CD drive, …

Slides:



Advertisements
Similar presentations
Lecture 13: 10/8/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
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.
Instruction Set-Intro
Chapter 2 Data Manipulation Dr. Farzana Rahman Assistant Professor Department of Computer Science James Madison University 1 Some sldes are adapted from.
1 ECE462/562 ISA and Datapath Review Ali Akoglu. 2 Instruction Set Architecture A very important abstraction –interface between hardware and low-level.
1 ECE369 ECE369 Chapter 2. 2 ECE369 Instruction Set Architecture A very important abstraction –interface between hardware and low-level software –standardizes.
ELEN 468 Advanced Logic Design
Systems Architecture Lecture 5: MIPS Instruction Set
Chapter 2 Instructions: Language of the Computer
Chapter 2.
COMP3221: Microprocessors and Embedded Systems Lecture 2: Instruction Set Architecture (ISA) Lecturer: Hui Wu Session.
CS1104 Assembly Language: Part 1
Implementation of a Stored Program Computer
Data Transfer & Decisions I (1) Fall 2005 Lecture 3: MIPS Assembly language Decisions I.
CSE378 MIPS ISA1 MIPS History MIPS is a computer family –R2000/R3000 (32-bit); R4000/4400 (64-bit); R8000; R10000 (64-bit) etc. MIPS originated as a Stanford.
MIPS assembly. Computer What’s in a computer? Processor, memory, I/O devices (keyboard, mouse, LCD, video camera, speaker), disk, CD drive, …
1 Layers of Computer Science, ISA and uArch Alexander Titov 20 September 2014.
Instruction Set Architecture
Computers organization & Assembly Language Chapter 0 INTRODUCTION TO COMPUTING Basic Concepts.
Implementation of a Stored Program Computer ITCS 3181 Logic and Computer Systems 2014 B. Wilkinson Slides2.ppt Modification date: Oct 16,
Lecture 4: MIPS Instruction Set Reminders: –Homework #1 posted: due next Wed. –Midterm #1 scheduled Friday September 26 th, 2014 Location: TODD 430 –Midterm.
1 Computer Architecture COSC 3430 Lecture 3: Instructions.
1 Instruction Set Architecture (ISA) Alexander Titov 10/20/2012.
Chapter 2 Instructions: Language of the Computer Part I.
Computer Organization and Architecture Instructions: Language of the Machine Hennessy Patterson 2/E chapter 3. Notes are available with photocopier 24.
CHAPTER 6 Instruction Set Architecture 12/7/
Computer Studies/ICT SS2
Microarchitecture. Outline Architecture vs. Microarchitecture Components MIPS Datapath 1.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO CS 219 Computer Organization.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 7, 8 Instruction Set Architecture.
Computer Organization Instructions Language of The Computer (MIPS) 2.
The Processor & its components. The CPU The brain. Performs all major calculations. Controls and manages the operations of other components of the computer.
MIPS Processor.
Computer Operation. Binary Codes CPU operates in binary codes Representation of values in binary codes Instructions to CPU in binary codes Addresses in.
CHAPTER 2 Instruction Set Architecture 3/21/
Computers’ Basic Organization
Computer Architecture & Operations I
Computer Architecture & Operations I
MIPS Assembly.
Assembly language.
A Closer Look at Instruction Set Architectures
Instruction Set Architecture
Microprocessor Systems Design I
Computer Architecture (CS 207 D) Instruction Set Architecture ISA
MIPS Assembly.
CSCI206 - Computer Organization & Programming
Instructions - Type and Format
Systems Architecture I (CS ) Lecture 5: MIPS Instruction Set*
Systems Architecture Lecture 5: MIPS Instruction Set
MIPS assembly.
MIPS assembly.
MIPS Assembly.
Computer Architecture
September 17 Test 1 pre(re)view Fang-Yi will demonstrate Spim
What is Computer Architecture?
Introduction to Microprocessor Programming
COMS 361 Computer Organization
What is Computer Architecture?
What is Computer Architecture?
Computer Architecture
MIPS assembly.
Review In last lecture, done with unsigned and signed number representation. Introduced how to represent real numbers in float format.
CPU Structure CPU must:
CS334: MIPS language _Mars simulator Lab 2_1
Systems Architecture I (CS ) Lecture 5: MIPS Instruction Set*
MIPS assembly.
Instruction Set Architecture
CSE378 Introduction to Machine Organization
Presentation transcript:

MIPS assembly

Computer  What’s in a computer?  Processor, memory, I/O devices (keyboard, mouse, LCD, video camera, speaker), disk, CD drive, …

A Typical Computer Processor Memory I/O device data instruction register ALU

Stored Program Concept 3/9/2016 CDA  Programs consist of instructions and data  Instructions are also represented as 0’s and 1’s  Before a program runs, it will be loaded and stored in memory; it can be read and written just like numbers  A program is executed instruction by instruction

GoogleEarth.exe 3/9/2016 CDA3100 6

Linux Kernel 3/9/2016 CDA3100 7

Registers and ALU  A processor has registers and ALU  Registers are where you store values (e.g., the value of a variable)  The values stored in registers are sent to the ALU to be added, subtracted, anded, ored, xored, …, then the result is stored back in a register. Basically it is the heart of the processor and does the calculation.

Why are we learning assembly Comparing to higher level languages such as C, assembly languages are more difficult to write, read, and debug. have poor portability – Every processor has its own assembly language. The code you wrote for MIPS is NOT going to run on Intel processors. Then why are we learning it? After learning the first assembly language, the second will be MUCH easier It brings us closer to the processor, which is the goal of this course.

MIPS ISA 3/9/2016 CDA  There are many different Instruction Set Architectures designed for different applications with different performance/cost tradeoff  Including Intel-32, PowerPC, MIPS, ARM ….  We focus on MIPS architecture  Microprocessor without Interlocked Pipeline Stages  A RISC (reduced instruction set computer) architecture  In contrast to CISC (complex instruction set computer)  Similar to other architectures developed since the 1980's  Almost 100 million MIPS processors manufactured in 2002  Used by NEC, Nintendo, Cisco, Silicon Graphics, Sony, …

A peek into the future… 3/9/2016 CDA

Abstract View of MIPS Implementation 3/9/2016 CDA

MIPS Instruction Set 3/9/2016 CDA  An instruction is a command that hardware understands  Instruction set is the vocabulary of commands understood by a given computer  It includes arithmetic instructions, memory access instructions, logical operations, instructions for making decisions

Arithmetic Instructions 3/9/2016 CDA  Each MIPS arithmetic instruction performs only one operation  Each one must always have exactly three variables add a, b, c # a = b + c  Note that these variables can be the same though  If we have a more complex statement, we have to break it into pieces

Arithmetic Instructions 3/9/2016 CDA  Example  f = (g + h) – (i + j)

Arithmetic Instructions 3/9/2016 CDA  Example  f = (g + h) – (i + j) add t0, g, h # temporary variable t0 contains g + h add t1, i, j # temporary variable t1 contains i + j sub f, t0, t1 # f gets t0 – t1

Operands of Computer Hardware 3/9/2016 CDA  In C, we can define as many as variables as we need  In MIPS, operands for arithmetic operations must be from registers  Note: in some architectures (including IA 32), some operands can be from memory directly  MIPS has thirty-two 32-bit registers

MIPS Registers 3/9/2016 CDA

Arithmetic Instructions 3/9/2016 CDA  Example  f = (g + h) – (i + j) #In MIPS, add can not access variables directly #because they are in memory # Suppose f, g, h, i, and j are in $s0, $s1, $s2, $s3, $s4 respectively add $t0, $s1, $s2 # temporary variable t0 contains g + h add $t1, $s3, $s4 # temporary variable t1 contains i + j sub $s0, $t0, $t1 # f gets t0 – t1

Memory Operands 3/9/2016 CDA  Since variables (they are data) are initially in memory, we need to have data transfer instructions  Note a program (including data (variables)) is loaded from memory  We also need to save the results to memory  Also when we need more variables than the number of registers we have, we need to use memory to save the registers that are not used at the moment  Data transfer instructions  lw (load word) from memory to a register  st (store word) from register to memory

Specifying Memory Address 3/9/2016 CDA  Memory is organized as an array of bytes (8 bits)

Specifying Memory Address 3/9/2016 CDA  MIPS uses words (4 bytes)  Each word must start at address that are multiples of 4  This is called alignment restriction  Big Endian

Example of Endianness 3/9/2016 CDA Store 0x at address 0x0000, byte-addressable

Example of Endianness 3/9/2016 CDA Store 0x at address 0x0000, byte-addressable

Using Load and Store 3/9/2016 CDA  Memory address in load and store instructions is specified by a base register and offset  This is called base addressing

Using Load and Store 3/9/2016 CDA  How to implement the following statement using the MIPS assembly we have so far?  Assuming the address of A is in $s3 and the variable h is in $s2 A[12] = h + A[8]

MIPS Assembly Programs 3/9/2016 CDA  Consists of MIPS instructions and data  Instructions are given in.text segments  A MIPS program can have multiple.text segments  Data are defined in.data segments using MIPS assembly directives .word, for example, defines the following numbers in successive memory words  See Appendix A A.10 (pp. A-45 – A-48) for details

Exercise 1  Suppose we have an array with starting address stored in $s0. We want to add the content of the first three elements, and put the result in the fourth element?  A[3] = A[2] + A[1] + A[0]