• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
MIPS-SPIM Taiwan
 

MIPS-SPIM Taiwan

on

  • 1,289 views

MIPS, SPIM

MIPS, SPIM

Statistics

Views

Total Views
1,289
Views on SlideShare
946
Embed Views
343

Actions

Likes
0
Downloads
17
Comments
0

13 Embeds 343

http://tsetsee-life.blogspot.com 158
http://tsetsee-life.blogspot.in 123
http://www.tsetsee-life.blogspot.com 40
http://www.tsetsee-life.blogspot.de 4
http://tsetsee-life.blogspot.tw 4
http://tsetsee-life.blogspot.jp 3
http://tsetsee-life.blogspot.fr 2
http://tsetsee-life.blogspot.com.au 2
http://www.tsetsee-life.blogspot.in 2
http://www.tsetsee-life.blogspot.jp 2
http://tsetsee-life.blogspot.de 1
http://tsetsee-life.blogspot.ru 1
http://tsetsee-life.blogspot.com.br 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    MIPS-SPIM Taiwan MIPS-SPIM Taiwan Presentation Transcript

    • Computer Organization and Structure 2011 SPIM & MIPS PROGRAMMING Created and Presented by Shu-Yang Lin, Hsun-Pei Wang, Liang-Tsen Shen Department of Information Management National Taiwan University
    • OUTLINE Homework 2 (Programming MIPS – Assignment) Assembly SPIM – Language Getting Programming Introduction Started to Assembly Language
    • ASSEMBLY LANGUAGEMachine language• Computer’s binary encodingAssembly language• Symbolic representation of a computer’s binary encodingAssembler• Translates assembly language into binary instructions
    • WHAT IS SPIM? MIPS32 simulator that reads and executes assembly language program written for SPIM. SPIM does NOT execute binary program.
    • REFERENCES OF SPIMOfficial website of SPIM: http://spimsimulator.sourceforge.net/Assemblers, Linkers, and the SPIM Simulator:http://pages.cs.wisc.edu/~larus/HP_Ap pA.pdfMIPS Instruction Reference:http://www.mrc.uidaho.edu/mrc/peopl e/jff/digital/MIPSir.html
    • QTSPIM - INSTALLATION http://spimsimulator.sourceforge.net /
    • QTSPIM - INSTALLATION Linux Windows Mac
    • QTSPIM - SCREENSHOT Text WindowRegister Window Data Window Console Window
    • MIPS ASSEMBLY LANGUAGE Operation Code (Opcode)
    • MIPS ASSEMBLY LANGUAGEMIPS Registers and Usage Convention n $zero constant 0 $v0, $v1 expression of a function $a0~$a3 argument 1~4 $t0~$t9 temporary registers $s0~$s7 save registers $sp stack pointer $fp frame pointer $ra return address…
    • MIPS ASSEMBLY LANGUAGESome Data Types in MIPS S .word, .half • 32/16 bit integer .byte • 8 bit integer .ascii, .asciiz • string .double, .float • floating point
    • MIPS SYSTEM CALLSSPIM provides a small set of operating-system- like services through the system call instruction.A program loads the system call code into register $v0 and arguments into registers $a0- $a3 (or $f12 for floating-point values).System calls that return values put their results in register $v0 (or $f0 for floating-point results).
    • MIPS SYSTEM CALLS $v0 FIGURE A.9.1 System services.
    • EXAMPLE – HELLO WORLDC vs MIPSint main() .data{ Mystr: .asciiz “Hello World¥n” printf(“Hello World¥”); return 0; .text main:} li $v0, 4 la $a0, Mystr syscall li $v0, 10 syscall
    • EXAMPLE – HELLO WORLDMIPS Architecture e .data Mystr: .asciiz “Hello World¥n” Yourint: .word 75 Hisarray: .word 100, 100, 100 .word 20 , 40 , 60 .word 1 , 2 , 3 .text ……
    • EXAMPLE – HELLO WORLDMIPS Architecture e .data .text main: # do anything you want …… # end of the program li $v0, 10 syscall
    • MIPS SYSTEM CALLS - EXAMPLE Output: “the answer = 5’’.data str: .asciiz "the answer = ".text li $v0, 4 # system call code for print_str la $a0, str # address of string to print syscall # print the string li $v0, 1 # system call code for print_int li $a0, 5 # integer to print syscall # print it FIGURE A.9.1 System services.
    • ASSEMBLER SYNTAXComment (#) Everything from the sharp sign to the end of the line is ignored.Identifier (A sequence of alphanumeric characters, _ , and .) Identifier are a sequence of alphanumeric characters, underbars (_), and dots (.) that do not begin with a number. Instruction Opcode Instruction opcodes are reserved words that are not valid identifiers. Label Labels are declared by putting them at the beginning of a line followed by a colon. PAGE 18
    • HOMEWORK
    • HOMEWORK This is an individual assignment Plagiarism will be heavily punished Write the following three programs in MIPS assembly language. (Must run correctly on SPIM) Simple Calculator Star Pyramid Pascal Triangle
    • DOCUMENTATION (20%) Detailed documentation for each program is required The following parts must be included:  Your name, student ID, and email address  Explanation of the design or the flow of each program  What you’ve learnt from writing the programs Problems or difficulties you’ve encountered during writing the programs are nice to be included in the document
    • PROBLEM 1. SIMPLE CALCULATOR Input:  Sample input / output • Two integer x, y ( x, y may be positive, negative or  zero) • An operator (+, ‐, *, /) Requirements: • Print  the correct answer. • Can do many calculations  iteratively • If the answer of division includes a  remainder please print it out • The file name is Calculator.s
    • PROBLEM 2: STAR PYRAMID Build a pyramid using stars(*) and white spaces given number of rows Example: Space # of rows = 5 4 * 3 * * * 2 * * * * * 1 * * * * * * * * * * * * * * * *
    • PROBLEM 2: STAR PYRAMID Input:  Number of rows of the pyramid: N (N>0) Sample Input Requirements:  Print the correct answer (Number of white spaces and stars should be correct)  File Name: StarPyramid.s Sample Output Pyramid may seemed to be a little inclined caused by the default display settings of the console window in QtSPIM  will NOT affect your score
    • PROBLEM 3: DEFORMATION OF PASCALTRIANGLEF(m ,n) = F(m-1 ,n-1)+ 2*F(m-1 ,n) (F(x, 0)=1 for all x and F(0, y)=0 for y>0) 0 1 2 3 4 5 … 0 1 0 0 0 0 0 … *2 1 1 1 0 0 0 0 … *2 *2 2 1 3 1 0 0 0 … *2 *2 *2 3 1 7 5 1 0 0 … 4 *2 *2 *2 *2 1 15 17 7 1 0 …
    • PROBLEM 3: DEFORMATION OF PASCALTRIANGLEInput:  Two integers m, n (m=1~20, n=1~99)Requirements:  Output F(m ,n) = F(m-1 ,n-1)+ 2*F(m-1 ,n) (F(x, 0)=1 for all x and F(0, y)=0 for y>0)  Print the correct answer  Can do many calculations iteratively  File Name: PascalDeform.s
    • HOW TO EXECUTE MY PROGRAM USING QTSPIM?Write your own assembly program, andsave it as .s file Simulator  Clear Registers Simulator Reinitialize Simulator Open your .s file Simulator  Run / Continue
    • SUBMISSION Deadline: 11:59pm, 1 Nov. (Tue.) You must submit at least the following files:  Calculator.s  StarPyramid.s  PascalDeform.s  (Your student id)_hwX_document.doc/pdf/docx Please put all your files in a directory named by your student id in uppercase, and then compress it into one zipped file. (e.g. zip/tgz …) You should upload your zipped file HW#2 to https://filestork.net/suv6oro7 before the deadline. The file name should be like B99xxxxxx.zip, eg. B99705099.zip Rename your file for multiple uploads, eg. B99705099_v2.zip, B99705099_v3.zip …
    • Remember to rename your fileSUBMISSION for multiple uploads!!! https://filestork.net/suv6oro7 7
    • GRADING GUIDELINES Description For Each Problem ProblemProgram runs without error messages 10%Program executes correctly 60%Documentation and description of 20%the programImplementation Detail 10%
    • CONTACT INFORMATIONTA Hours @ 管五 503-C  Shu-Yang Lin (林書漾) Fri. 10:00~12:00  Hsun-Pei Wang (王珣沛) Fri. 10:00~12:00  Liang-Tsen Shen (沈亮岑) Mon. 10:00~12:00Contact us if you have any problem  林書漾 young@cmlab.csie.ntu.edu.tw  王珣沛 garfieldduck@cmlab.csie.ntu.edu.tw  沈亮岑 olga@cmlab.csie.ntu.edu.tw
    • DEADLINE2011/11/1 (Tue.)Late submission policy: 10% off from your total score each day after the deadline
    • THANK YOU FORYOUR ATTENTIONAny Questions?