Introduction to Lab #1 José Nelson Amaral.

Slides:



Advertisements
Similar presentations
MIPS Assembly Language CPSC 321 Computer Architecture Andreas Klappenecker.
Advertisements

5Z032 Processor Design SPIM, a MIPS simulator Henk Corporaal
SPRING 2015 QtSpim Demo & Tutorial. 2 By DGP Outline How to write your own MIPS assembly language program How to use QtSpim simulator.
SPIM and MIPS programming
Fall EE 333 Lillevik 333f06-l4 University of Portland School of Engineering Computer Organization Lecture 4 Assembly language programming ALU and.
Some Samples of MIPS Assembly Language Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University.
Syscall in MIPS Xinhui Hu Yuan Wang.
MIPS Function Continued
1 Nested Procedures Procedures that don't call others are called leaf procedures, procedures that call others are called nested procedures. Problems may.
MIPS Assembly Language Programming
Ch. 8 Functions.
1 Computer Architecture MIPS Simulator and Assembly language.
The University of Adelaide, School of Computer Science
Assembly Language Working with the CPU.
1 COMS 361 Computer Organization Title: Instructions Date: 9/28/2004 Lecture Number: 10.
ECE 0142 Recitation #5.
MIPS Assembly Language I Computer Architecture CPSC 321 Andreas Klappenecker.
Feb 18, 2009 Lecture 4-2 instruction set architecture (Part II of [Parhami]) MIPS encoding of instructions Spim simulator more examples of MIPS programming.
1 Lecture 6: Compilers, the SPIM Simulator Today’s topics:  SPIM simulator  The compilation process Additional TA hours: Liqun Cheng, legion at.
Computer Organization - Syscalls David Monismith Jan. 28, 2015 Based on notes from Patterson and Hennessy Text and from Dr. Bill Siever.
CSC 3210 Computer Organization and Programming Chapter 1 THE COMPUTER D.M. Rasanjalee Himali.
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.
Lecture # 1 SPIM & MIPS Programming. SPIM SPIM is a MIPS32 simulator that reads and executes assembly language program written for SPIM. Platform -Unix,
Lecture 10: MIPS Simulator Today’s topic –SPIM Simulator Readings –Appendix B 1.
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.
More on MIPS programs n SPIM does not support everything supported by a general MIPS assembler. For example, –.end doesn’t work Use j $ra –.macro doesn’t.
Lecture 161 Lets examine a SPIM program in detail. io.asm This program is a simple routine which demonstrates input/output using assembly code. SPIM.
1 Lecture 7: MARS, Computer Arithmetic Today’s topics:  MARS intro  Numerical representations  Addition and subtraction.
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.
Intro to SPIM Justin Fiore Nathan Parish. Installing SPIM on Windows Download pcspim.zip from the SPIM website:
MIPS Assembly Language Chapter 13 S. Dandamudi To be used with S. Dandamudi, “Introduction to Assembly Language Programming,” Second Edition, Springer,
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
MIPS assembly syntax Home Assignment 3 Assigned. Deadline 2016 February 14, Sunday.
CS 312 Computer Architecture & Organization
Function Calls in Assembly MIPS R3000 Language (extensive use of stack) Updated 7/11/2013.
Computer Architecture & Operations I
Computer Architecture Instruction Set Architecture
MIPS Instruction Set Advantages
Lecture 7: MARS, Computer Arithmetic
CS 286 Computer Organization and Architecture
Lecture 4: MIPS Instruction Set
ACOE301: Computer Architecture II Labs
MIPS assembly syntax Comments
RISC Concepts, MIPS ISA Logic Design Tutorial 8.
Assembly Programming using MIPS R3000 CPU
MIPS coding.
Week 5 Computers are like Old Testament gods; lots of rules and no mercy. Joseph Campbell.
SPIM Syscalls.
MPIS Instructions Functionalities of instructions Instruction format
Assembler Directives Example program: .data # DATA segment city: .asciiz “Seattle” .align 2 num: .word 2210, 2341, 26, 0x022ec,
Solutions Chapter 2.
MIPS coding.
The University of Adelaide, School of Computer Science
MIPS Functions.
Lecture 7: Examples, MARS, Arithmetic
MIPS Procedures.
Review.
MIPS function continued
Компьютерийн зохион байгуулалт, ассемблер CS201
COMS 361 Computer Organization
CS 286 Computer Organization and Architecture
Assembly Programming using MIPS R3000 CPU
Review.
MIPS coding.
Generalities for Assembly Language
MIPS Assembly Language Programming Computer Architecture
Program Assembly.
CS 286 Computer Architecture & Organization
Week 5 Computers are like Old Testament gods; lots of rules and no mercy. Joseph Campbell.
Presentation transcript:

Introduction to Lab #1 José Nelson Amaral

General Intro to 229 Labs In 229, a “lab” is a programming assignment: A lab requires many more hours of work than the time allocated for lab sessions. Lab sessions are “consulting hours” when TAs are available to answer questions and to help. Reading/work prior to the lab date/time is essential. The lab assignments will be progressively more difficult, and will require more time as the term advances. A CMPUT 229 lab is not a “lab” in the sense of a chemistry lab.

Part #1 Read Appendix titled "Assemblers, Linkers, and the SPIM Simulator" (specially section 9): In the 4th edition of the book, this is appendix B In the 5th edition of the book, this is appendix A Read the SPIM Tutorial (available online): http://pages.cs.wisc.edu/~larus/HP_AppA.pdf

Part #2 Self-guided tutorial-style introduction to usage of XSPIM. Part #3 Simple exercise to illustrate use of SPIM.

Part #4 Understand data storage in memory. Question #6: Understand little/big endianess and conversion to/from ASCII. Question #7: Understand 2-complement integers Question #8: Assembly directives

Part #5: Find bugs in lab1-broken.s The program lab1-broken.s was written to check whether a string is a palindrome. It should check if “racecar” Is the same as But lab1-broken.s is not working as it should. Your job is to read and understand the program and to report what are the errors in this program.

Part #5 submission You will describe the bugs in a text file called bugs.txt and submit this file. The solution for parts 1-5 are answers to the questions in the lab assignment. There is no specified format for these answers. Just use a reasonable formatting and provide clear and concise answers.

System call table P-H pp. A-44 Chapter 2 — Instructions: Language of the Computer — 8

Part #6: The calculator Program Write a MIPS assembly program that acts as a calculator for reverse Polish notation/postfix expressions. Infix notation: Postfix notation: (1 + 2) * 3 = 9 1 2 + 3 * = 9

Types of input tokens for calculator Token Type Value OPERAND non-negative integer PLUS -1 MINUS -2 TERMINATION -3

Operation of the calculator read a token from the input list if token == OPERAND (a non-negative value) push value into the stack if token == PLUS or token == MINUS pop two topmost values from the stack perform operation push result into the stack if token == TERMINATION print out the value that is on top of the stack terminate the program

How does the stack grow? Stack: 0x10001024 0x10001020 0x1000101C TopOfTheStack 5 3 1 1 4 4

Input Token List: Stack: 0x1000100C 0x10001024 0x10001008 0x10001020 5 1 -2 -3 4 5 5 1 1 4 Token Type: TERMINATION OPERAND MINUS

Formatting and Style Check the lab grading marksheet

The University of Adelaide, School of Computer Science 28 May 2018 Assembler Syntax comments begin with a sharp sign (#) and run to the end of the line. identifiers are alphanumeric sequences, underbars (_), and dots (.) that do not begin with a number. labels are identifiers placed at the beginning of a line, and followed by a colon. .data item: .word 1 .text .globl main main: lw $s3, item Loop: add $t1, $s3, $s3 # $t1 ← 2 * i add $t1, $t1, $t1 # $t1 ← 4 * i add $t1, $t1, $s6 # $t1 ← Addr(save[i]) lw $t0, 0($t1) # $t0 ← MEM[save[i]] bne $t0, $s5, Exit # if save[I] ≠ k goto Exit add $s3, $s3, $s4 # i ← i + j j Loop # goto Loop Exit: Chapter 2 — Instructions: Language of the Computer — 15 P-H. p. B-10 Chapter 2 — Instructions: Language of the Computer

The University of Adelaide, School of Computer Science 28 May 2018 Assembler Directives .data identifies the beginning of the data segment (in this example this segment contains a single word). .word 1 stores the decimal number 1 in 32-bits (4 bytes) .text identifies the beginning of the text segment (where the instructions of the program are stored). .globl main declares the label main global (so that it can be accessed from other files). .data item: .word 1 .text .globl main main: lw $s3, item Loop: add $t1, $s3, $s3 # $t1 ← 2 * i add $t1, $t1, $t1 # $t1 ← 4 * i add $t1, $t1, $s6 # $t1 ← Addr(save[i]) lw $t0, 0($t1) # $t0 ← MEM[save[i]] bne $t0, $s5, Exit # if save[I] ≠ k goto Exit add $s3, $s3, $s4 # i ← i + j j Loop # goto Loop Exit: Chapter 2 — Instructions: Language of the Computer — 16 Chapter 2 — Instructions: Language of the Computer

The University of Adelaide, School of Computer Science 28 May 2018 File lab1-p1.s pseudo instruction that loads the immediate value in the register exit: div $t5, $t1, $a1 li $v0, 4 la $a0, outputMsg syscall li $v0, 1 add $a0, $0, $t5 la $a0, newln jr $ra .data val: .word 12, 34, 56, 78, 90 outputMsg: .asciiz "\n Result = " newln: .asciiz "\n\n" OS-style call to obtain services from SPIM: $a0-$a3: arguments $v0: system call code before the call; return value after the call. (see page A-43). # What's going on here ? .text main: li $a1, 5 la $t0, val xor $t1, $t1, $t1 xor $t2, $t2, $t2 loop: sub $t3, $a1, $t2 blez $t3, exit lw $t4, 0($t0) add $t1, $t1, $t4 add $t2, $t2, 1 addu $t0, $t0, 4 j loop pseudo instruction that loads the address of specified label into register Chapter 2 — Instructions: Language of the Computer — 17 Chapter 2 — Instructions: Language of the Computer

Files to Submit There are three files to submit: lab1.txt lab1.s bugs.txt Make sure lab1.s does not contain a main label. Your code must go under the label ‘calculator’.