COMS 361 Computer Organization

Slides:



Advertisements
Similar presentations
Henk Corporaal TUEindhoven 2011
Advertisements

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.
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
Introduction to SPIM Simulator
1 ECE462/562 ISA and Datapath Review Ali Akoglu. 2 Instruction Set Architecture A very important abstraction –interface between hardware and low-level.
10/9: Lecture Topics Starting a Program Exercise 3.2 from H+P Review of Assembly Language RISC vs. CISC.
CS1104 – Computer Organization PART 2: Computer Architecture Lecture 5 MIPS ISA & Assembly Language Programming.
ELEN 468 Advanced Logic Design
SPIM and MIPS programming
1 Computer Architecture MIPS Simulator and Assembly language.
1 COMS 361 Computer Organization Title: Instructions Date: 9/28/2004 Lecture Number: 10.
MIPS Assembly Language I Computer Architecture CPSC 321 Andreas Klappenecker.
CS 536 Spring Code generation I Lecture 20.
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
MIPS Instruction Set Advantages
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
CWRU EECS 322 March 8, 2000 The SPIM simulator EECS 322: Computer Architecture.
R3000/001 Assembly Programming using MIPS R3000 CPU R3000 CPU Chip Manufactured by IDT What is MIPS R3000 Processor? A 32-bit RISC CPU developed by MIPS.
COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer Science York University Handout # 3: MIPS Instruction Set I Topics: 1.
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
Lecture 10: MIPS Simulator Today’s topic –SPIM Simulator Readings –Appendix B 1.
Computer Architecture CSE 3322 Lecture 3 Assignment: 2.4.1, 2.4.4, 2.6.1, , Due 2/3/09 Read 2.8.
MS108 Computer System I Lecture 3 ISA Prof. Xiaoyao Liang 2015/3/13 1.
Computer Organization Rabie A. Ramadan Lecture 3.
Computer Architecture CSE 3322 Lecture 4 Assignment: 2.4.1, 2.4.4, 2.6.1, , Due 2/10/09
MIPS Assembly.
Computer Architecture Instruction Set Architecture
MIPS Instruction Set Advantages
Computer Architecture Instruction Set Architecture
MIPS Coding Continued.
Lecture 4: MIPS Instruction Set
ELEN 468 Advanced Logic Design
ECE3055 Computer Architecture and Operating Systems MIPS ISA
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
Assembly Programming using MIPS R3000 CPU
Computer Architecture (CS 207 D) Instruction Set Architecture ISA
CS170 Computer Organization and Architecture I
MIPS coding.
Instructions - Type and Format
Lecture 4: MIPS Instruction Set
MPIS Instructions Functionalities of instructions Instruction format
Henk Corporaal TUEindhoven 2010
MIPS Instruction Encoding
The University of Adelaide, School of Computer Science
ECE232: Hardware Organization and Design
The University of Adelaide, School of Computer Science
MIPS Instruction Encoding
MIPS History MIPS is a computer family
Instruction encoding The ISA defines Format = Encoding
Lecture 5: Procedure Calls
Review.
MIPS History MIPS is a computer family
Computer Instructions
COMS 361 Computer Organization
COMS 361 Computer Organization
COMS 361 Computer Organization
Assembly Programming using MIPS R3000 CPU
MIPS History MIPS is a computer family
MIPS Coding Continued.
MIPS coding.
Computer Architecture
Introduction Lab1 A crash course in assembler programming
Instruction Set Architecture
Week 5 Computers are like Old Testament gods; lots of rules and no mercy. Joseph Campbell.
Presentation transcript:

COMS 361 Computer Organization Title: Instructions Date: 9/23/2004 Lecture Number: 9

Announcements Homework 3 Due 9/28/04

Review Instructions MIPS load and store instruction format MIPS immediate instruction format Addressing MIPS branch instructions and format

Outline Instructions MIPS history SPIM unconditional branch J-Type instruction format MIPS history SPIM MIPS simulator

Control Flow MIPS also provides an unconditional branch instruction: j label Introduce a new type of instruction format j-type for branch instructions

Control Flow C++ code: if (i == j) { f = g + h; } else { f = g – h; } MIPS code: bne $s3, $s4, Else add $s0, $s1, $s2 j Endif Else: sub $s0, $s1, $s2 Endif:blah beq $s4, $s5, EQ sub $s3, $s4, $s5 j Endif EQ: add $s3,$s4,$s5 Endif:blah

Control Flow Unconditional branch instruction requires only an op code and an address to jump to Op code Address

Summary so far Instruction Meaning add $s1,$s2,$s3 $s1 = $s2 + $s3 sub $s1,$s2,$s3 $s1 = $s2 – $s3 lw $s1,100($s2) $s1=Memory[$s2+100] sw $s1,100($s2) Memory[$s2+100]=$s1 bne $s4,$s5,L Next instr. is at L if $s4 != $s5 beq $s4,$s5,L Next instr. is at Label if $s4 == $s5 j Label Next instr. is at Label

Summary so far Instruction formats R op rs rt rd shamt funct I op rs rt 16 bit address J op 26 bit address

MIPS Background early 1980’s RISC: Reduced Instruction Set Computer Speed up the common, simple instructions Speed penalty for the uncommon instructions Large gain in performance CICS: Complex Instruction Set Computer Many complicated instructions Speed penalty for the simple instructions

MIPS John Hennessy at Stanford designed and fabricated a RISC called MIPS Play of the MIPS measure of performance Microprocessor without Interlocking Pipeline Stages

MIPS Memory Layout Memory cells consist of 8-bits (byte) Numbered (addressed) starting at 0 and increasing to the maximum allowable number Programs consist of Instructions Data Address Contents 0x00000000 0x00 0x00000001 0x0A 0x00000002 0x3E 0x00000003 0x10 0xFFFFFFFE 0xf0 0xFFFFFFFF 0x15 …

MIPS Memory Layout Memory must be organized Prevent data from being fetched as instructions Prevent instructions from being treated as data A programs address space is composed of three parts Text segment Contains program instructions Data segment Contains program data Stack segment Supports function calls

MIPS Memory Layout 0x7FFFFFFF Stack Segment … Data Segment Text Segment Reserved Stack starts at the top address space and grows down Data that instructions operate on 0x10000000 Instructions 0x00400000

MIPS Registers Register name Number Convention $zero $0 Constant 0 $at $1 Reserved for assembler $v0 - $v1 $2 - $3 Expression evaluation and function results $a0 - $a3 $4 - $7 Function arguments $t0 - $t7 $8 - $15 Temporary (not saved) $s0 - $s7 $16 - $23 Temporary (saved) $t8 - $t9 $24 - $25 $k0 - $k1 $26 - $27 Reserved for the OS kernel $gp $28 Global pointer (holds constant and global values) $sp $29 Stack pointer (last used location) $fp $30 Frame pointer (supports function calls) $ra $31 Return address for function calls

MIPS Registers 16 floating point registers name $f0 - $f15

SPIM A simulator for the MIPS R2000/R3000 processors Read and execute files containing assemble language Includes Debugger Interface Some operating system services Actually runs programs for MIPS computers How do we get a program into SPIM?

SPIM I/O The operating system kernel is the lowest level software running on a machine A program makes a system call to request the kernel to perform I/O operations The OS kernel implements I/O requests by communicating directly with the hardware An OS may have several hundred system calls SPIM provides 10 OS-like services Made through a syscall instruction Simulation of a simple OS

SPIM I/O SPIM programs request an I/O service Load the system call code into register $v0 Load arguments into registers $a0 - $a3 $f12 for floating point values

SPIM I/O Service Call code Arguments Result print_int 1 $a0 = integer print_float 2 $f12 = float print_double 3 $f12 = double print_string 4 $a0 = string read_int 5 integer in $v0 read_float 6 float in $f0 read_double 7 double in $f0 read_string 8 $a0 = buffer, $a1 = length sbrk 9 $a0 = amount address in $v0 exit 10

Show me the code! SPIM Program MIPS/SPIM program files usually end in .s File is loaded into SPIM Assembled into MIPS machine code Executed and debugged in SPIM

SPIM Program ## exit.s - program simply makes a system call to exit ## ## text segment .text main: addi $v0, $zero, 10 # exit call code syscall # terminate program execution ## data segment ## end exit.s

SPIM Program ## exit.s - program simply makes a system call to exit ## text segment .text main: addi $v0, $zero, 10 # exit call code syscall # terminate program execution ## data segment ## end exit.s Comments in MIPS assembly code are denoted by the sharp (#) sign Similar to the C++ (//) comment. Starts at instance and goes to the end of the line Assembly code in NOT self-documenting. Use comments liberally, like associated with each instruction

SPIM Program ## exit.s - program simply makes a system call to exit ## text segment .text main: addi $v0, $zero, 10 # exit call code syscall # terminate program execution ## data segment ## end exit.s Comments indicating the start of the code After text segment is converted into its binary representation, it is stored in the text memory segment . indicates an assembler directive .text directs the assembler to treat what follows as instructions

Text Segment The source code format is relatively standard Proper indentation is fundamentally important in assembly language programming [] indicate optional fields Not all fields appear on a line of code [label:] operation [operand], [operand], [operand] [# comment]

SPIM Program ## exit.s - program simply makes a system call to exit ## text segment .text main: addi $v0, $zero, 10 # exit call code syscall # terminate program execution ## data segment ## end exit.s main: is a label Just as C++ programs need a main function, MIPS programs need a main label main: labels the first instruction of the program

Labels : Labels associate a symbol with Tells the assembler that the proceeding alphanumerics including (_) and (.) constitutes the label Opcodes are reserved words and are not permitted to be used as labels Use appropriate names for labels Labels associate a symbol with The address of an instruction The address of a variable

SPIM Program ## exit.s - program simply makes a system call to exit ## text segment .text main: addi $v0, $zero, 10 # exit call code syscall # terminate program execution ## data segment ## end exit.s Program is to simple call the OS with the exit call code In the real world the OS cleans up after the program The call code for exit is the decimal number 10, which needs to be put into the $v0 register (convention) addi with the proper operands can achieve this goal

SPIM Program ## exit.s - program simply makes a system call to exit ## text segment .text main: addi $v0, $zero, 10 # exit call code syscall # terminate program execution ## data segment ## end exit.s Call the OS with the proper call code in the $v0 register

Show me the program execute! SPIM Program Show me the program execute! And some things about SPIM City!! exit.s hello.s

MIPS Instructions MIPS instruction set architecture Assembly instructions that convert into machine (binary) instructions Assembly instructions can be converted directly into machine instructions One-to-one mapping Assembly instructions can be converted into more than one machine instruction One-to-many mapping Native machine instructions Pseudo-machine instructions Consists of more than one native machine instruction

MIPS Instructions Is that a real instruction or a Sears instruction?