Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 286 Computer Organization and Architecture

Similar presentations


Presentation on theme: "CS 286 Computer Organization and Architecture"— Presentation transcript:

1 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 FirstProgram/001

2 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

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

4 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

5 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, # Load "1" to register $S1 li $s2, # Load "2" (decimal "2") to register $S2 add $s0, $s1, $s # Add register S1 and S2 and save the # result to S0 register jr $ # 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

6 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

7 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

8 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

9 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

10 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

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

12 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

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

14 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

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

16 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

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

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

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

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

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


Download ppt "CS 286 Computer Organization and Architecture"

Similar presentations


Ads by Google