CS 286 Computer Organization and Architecture

Slides:



Advertisements
Similar presentations
King Fahd University of Petroleum and Minerals King Fahd University of Petroleum and Minerals Computer Engineering Department Computer Engineering Department.
Advertisements

Lecture 13: 10/8/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Write a program step by step. Step 1: Problem definition. Given the coordinate of two points in 2-D space, compute and print their straight distance.
Dr. Ken Hoganson, © August 2014 Programming in R COURSE NOTES 2 Hoganson Language Translation.
The 8051 Microcontroller and Embedded Systems
SPIM and MIPS programming
Syscall in MIPS Xinhui Hu Yuan Wang.
MIPS Assembly Language Programming
1 Computer Architecture MIPS Simulator and Assembly language.
Assembly Language Working with the CPU.
1 COMS 361 Computer Organization Title: Instructions Date: 9/28/2004 Lecture Number: 10.
SPIM : A MIPS Simulator Archi & Net Lab 이용석
MIPS Instruction Set Advantages
Chapter 2 Software Tools and Assembly Language Syntax.
ICS312 Set 4 Program Structure. Outline for a SMALL Model Program Note the quiz at the next lecture will be to reproduce this slide.MODEL SMALL.586 ;
First Programming Assignment For MIPS R3000 Processor Department of Computer Science Southern Illinois University Edwardsville Fall, 2015 Dr. Hiroshi Fujinoki.
MIPS R3000 Subroutine Calls and Stack Department of Computer Science Southern Illinois University Edwardsville Fall, 2015 Dr. Hiroshi Fujinoki
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text.
Datapath Architecture Department of Computer Science Southern Illinois University Edwardsville Fall, 2015 Dr. Hiroshi Fujinoki
1 Compilers Modern Compiler Design Supplementary Note 2 SPIM Overview NCYU C. H. Wang.
MIPS coding. slt, slti slt $t3, $t1, $t2 – set $t3 to be 1 if $t1 < $t2 ; else clear $t3 to be 0. – “Set Less Than.” slti $t3, $t1, 100 – set $t3 to be.
Assembly Language A Brief Introduction. Unit Learning Goals CPU architecture. Basic Assembler Commands High level Programming  Assembler  Machine Language.
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.
Lecture # 1 SPIM & MIPS Programming. SPIM SPIM is a MIPS32 simulator that reads and executes assembly language program written for SPIM. Platform -Unix,
Copyright 2006 by Timothy J. McGuire, Ph.D. 1 MIPS Assembly Language CS 333 Sam Houston State University Dr. Tim McGuire.
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.
MIPS coding. slt, slti slt $t3, $t1, $t2 – set $t3 to be 1 if $t1 < $t2 ; else clear $t3 to be 0. – “Set Less Than.” slti $t3, $t1, 100 – set $t3 to be.
Copyright 2006 by Timothy J. McGuire, Ph.D. 1 MIPS Assembly Language CS 333 Sam Houston State University Dr. Tim McGuire.
3-Apr-2006cse spim © 2006 DW Johnson and University of Washington1 SPIM simulator CSE 410, Spring 2006 Computer Systems
Lecture 16: 10/29/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
CS501 Advanced Computer Architecture Lecture 29 Dr.Noor Muhammad Sheikh.
Writing an Assembly-language program MIPS assembly language using MARS: MIPS Assembler and Runtime Simulator CS-2710 Dr. Mark L. Hornick 1.
CS 312 Computer Architecture & Organization
MIPS Assembly Language Programming
INTRODUCTION TO AVRASSEMBLY PROGRAMMING
MIPS Instruction Set Advantages
Introduction to Lab #1 José Nelson Amaral.
Computer Organization A Quick Tour for Introduction
CS 286 Computer Organization and Architecture
ACOE301: Computer Architecture II Labs
The 8051 Microcontroller and Embedded Systems
CS 286 Computer Organization and Architecture
CS 286 Computer Organization and Architecture
Assembly Programming using MIPS R3000 CPU
MIPS coding.
Week 5 Computers are like Old Testament gods; lots of rules and no mercy. Joseph Campbell.
MIPS coding.
MARIE: An Introduction to a Simple Computer
CS-401 Assembly Language Programming
CS 286 Computer Organization and Architecture
CS 286 Computer Architecture & Organization
Computer Organization A Quick Tour for Introduction
Instruction Rescheduling and Loop-Unroll
Reducing pipeline hazards – three techniques
Assembly Programming using MIPS R3000 CPU
8051 ASSEMBLY LANGUAGE PROGRAMMING
MIPS coding.
Chapter 6 Programming the basic computer
Process Synchronization
CS334: MIPS language _Mars simulator Lab 2_1
Department of Computer Science
Department of Computer Science
Threads: Light-Weight Processes
Process Synchronization
Light-Weight Process (Threads)
CS 286 Computer Architecture & Organization
Week 5 Computers are like Old Testament gods; lots of rules and no mercy. Joseph Campbell.
MIPS R3000 Subroutine Calls and Stack
Computer Architecture and System Programming Laboratory
COMPUTER ARCHITECTURE
Presentation transcript:

CS 286 Computer Organization and Architecture First Programming Assignment For MIPS R3000 Processor Department of Computer Science Southern Illinois University Edwardsville Fall, 2018 Dr. Hiroshi Fujinoki E-mail: hfujino@siue.edu FirstProgram/001

Assembly Programming using MIPS R3000 CPU What is MIPS R3000 Processor? A 32-bit RISC CPU developed by MIPS Technologies Inc., R3000 CPU Chip Manufactured by IDT Used for high-performance desktops such as workstations Many venders manufacture the chip (NEC, IDT, Toshiba) R3000/001

Assembly Programming using MIPS R3000 CPU The process of assembly programming We start from here! SPIM Simulator does these for us R3000/002

w/ “.asm” file extension CS 286 Computer Organization and Architecture Start developing your first assembly program using SPIM Your source code file w/ “.asm” file extension Prepare your source code Step #1 Three major components in your SPIM program “Test.asm” (1) Data Section (2) Program Definition (3) Program Body FirstProgram/001

CS 286 Computer Organization and Architecture “#” indicates an in-line comment Overview: an assembly program source code for SPIM # ############################################################### # # Test2.asm # # # # Sample assembly code No. 2 for testing SPIM Simulator. # # This sample program is just for understanding SPIM assembler. # .text .globl main main: li $s1, 1 # Load "1" to register $S1 li $s2, 2 # Load "2" (decimal "2") to register $S2 add $s0, $s1, $s2 # Add register S1 and S2 and save the # result to S0 register jr $31 # Return from main (stop the program) # END OF THE LINES ############################################### “.text” label declares the beginning of your assembly program source code Declaring your program body name The program body Assembly instructions Stop your assembly program FirstProgram/002

CS 286 Computer Organization and Architecture The three components in your SPIM program 1. “Data” Section This section is “optional” This is the place where you keep any constants in your program - Error message - Prompt message for user input - Any constant, such as “3.14” - Input/Output buffers (contents vary, but buffer size unchanged) The data section is declared by “.data” assembler directive SPIM assumes the data section at the beginning - Because the program codes are supposed to be at the end FirstProgram/003

CS 286 Computer Organization and Architecture The three components in your SPIM program (continued) 2. “Program Definition” Section This is the place where you declare your assembly program The program definition section is declared by “.text” assembler directive The beginning label of your assembly program declared by “.globl name_of_your_beginning_label”  The program definition section should be the simplest (and shortest) We will see this in examples later FirstProgram/004

CS 286 Computer Organization and Architecture The three components in your SPIM program (continued) 3. “Program Body” Section This is the place where you write your program (assembly instructions) You must start with the beginning label you declared - If you declare “.globl main” in program definition - You must start your program with “main:” label Your program should be stopped by “jr $31” instruction  If you forget that, the CPU continues to execute What instructions will be executed? We never know before. FirstProgram/005

CS 286 Computer Organization and Architecture Dissection: Program Body Section Instruction field Label field Comment field Beginning of a program main: jr $31 # Stop program Your program Stop your program FirstProgram/006

CS 286 Computer Organization and Architecture This is when we start PC-SPIM for the first time Open your program source code Start using SPIM FirstProgram/007

CS 286 Computer Organization and Architecture Start using SPIM (continued) Specify your source code file FirstProgram/008

CS 286 Computer Organization and Architecture Start using SPIM (continued) Once assembly program is opened, the four windows will be automatically re-loaded FirstProgram/009

CS 286 Computer Organization and Architecture Close-Look (1): “Register” Window “Register” window Contents of registers FirstProgram/010

CS 286 Computer Organization and Architecture Close-Look (2): “Text Segment” Window Assembler instructions (from your source code) Address for your instructions Generated machine codes (in Hexadecimal expression) FirstProgram/011

CS 286 Computer Organization and Architecture Close-Look (3): “Data Segment” Window Address of major program components are shown FirstProgram/012

CS 286 Computer Organization and Architecture Close-Look (4): “Message” Window Messages from SPIM Assembler are shown here Most probably, the least important window ... FirstProgram/013

CS 286 Computer Organization and Architecture To run your program, press this button FirstProgram/014

CS 286 Computer Organization and Architecture Specify starting address of your assembly program (optional) Text Segment Window FirstProgram/015

CS 286 Computer Organization and Architecture Examining registers for the result of program execution FirstProgram/016

CS 286 Computer Organization and Architecture The three components in your SPIM program (continued) FirstProgram/017

CS 286 Computer Organization and Architecture The three components in your SPIM program (continued) The results of program execution FirstProgram/018