Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.

Slides:



Advertisements
Similar presentations
Branches Two branch instructions:
Advertisements

Arrays First step is to reserve sufficient space for the array.
MIPS Assembly Language CPSC 321 Computer Architecture Andreas Klappenecker.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 5: Data Transfer Instructions / Control Flow Instructions Partially adapted from Computer.
1 CDA 3101 Discussion Section 03.  Problem The following problems deal with translating from C to MIPS. Assume that the variables f, g, h, i and.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
SPIM and MIPS programming
1 Today’s lecture  Last lecture we started talking about control flow in MIPS (branches)  Finish up control-flow (branches) in MIPS —if/then —loops —case/switch.
Syscall in MIPS Xinhui Hu Yuan Wang.
MIPS Function Continued
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.
Feb 18, 2009 Lecture 4-2 instruction set architecture (Part II of [Parhami]) MIPS encoding of instructions Spim simulator more examples of MIPS programming.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text.
9/29: Lecture Topics Memory –Addressing (naming) –Address space sizing Data transfer instructions –load/store on arrays on arrays with variable indices.
Computer Organization - Syscalls David Monismith Jan. 28, 2015 Based on notes from Patterson and Hennessy Text and from Dr. Bill Siever.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text.
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.
Character Data and 32-bit Constants (Lecture #20) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Computer Organization – Memory Access David Monismith Jan. 30, 2015 Based upon notes by Dr. Bill Siever and the Patterson and Hennessy Text.
Ch2b- 2 EE/CS/CPE Computer Organization  Seattle Pacific University Thanks for all the Memory! When 32 registers just won’t do. Many times (almost.
Oct. 25, 2000Systems Architecture I1 Systems Architecture I (CS ) Lecture 9: Alternative Instruction Sets * Jeremy R. Johnson Wed. Oct. 25, 2000.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
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.
Control Structures Computer Organization I 1 October 2009 © McQuain, Feng & Ribbens Conditional Control Structure if ( i == j ) h = i + j;
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
The SPIM Trap Handler Syscall Trap handler services String operations File operations Memory allocation Central Connecticut State University, MIPS Tutorial.
Addressing Modes. Register Addressing Immediate Addressing Base Addressing Indexed Addressing PC-Relative Addressing.
Indexed Addressing addition to implementing new instructions, the extended assembler implements a new addressing mode. This is indexed addressing, a mode.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text.
Control Structures Computer Organization I 1 October 2009 © McQuain, Feng & Ribbens Conditional Control Structure if ( i < j ) goto A; else.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patterson and Hennessy Text.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text.
MIPS Arrays Computer Organization I 1 September 2010 © McQuain, Array Declaration and Storage Allocation The first step is to reserve sufficient.
Function Calls in Assembly MIPS R3000 Language (extensive use of stack) Updated 7/11/2013.
Computer Architecture & Operations I
MIPS Assembly Language Programming
Computer Architecture & Operations I
Arrays First step is to reserve sufficient space for the array.
CS2100 Computer Organisation
Computer Science 210 Computer Organization
MIPS Coding Continued.
Parallel Shared Memory
Conditional Control Structure
Instructions - Type and Format
Week 5 Computers are like Old Testament gods; lots of rules and no mercy. Joseph Campbell.
Assembler Directives Example program: .data # DATA segment city: .asciiz “Seattle” .align 2 num: .word 2210, 2341, 26, 0x022ec,
MIPS Functions.
MIPS coding.
MIPS coding.
Компьютерийн зохион байгуулалт, ассемблер CS201
MIPS function continued
Review.
Introduction to Computer Science
MIPS Assembly Language Programming Computer Architecture
9/27: Lecture Topics Memory Data transfer instructions
Week 5 Computers are like Old Testament gods; lots of rules and no mercy. Joseph Campbell.
Conditional Control Structure
Introduction to SPIM Simulator
Conditional Branching (beq)
Presentation transcript:

Computer Organization CS345 David Monismith Based upon notes by Dr. Bill Siever and notes from the Patternson and Hennessy Text

Review MIPS Loops review with problems

Loops Assume we wish to determine if two strings are of the same length using MIPS, the solution requires comparison of the lengths of two strings. Before this comparison can be performed, the string lengths must be computed. Let's look at an example in a high level language, first though. Recall that we cannot compute the length of a string in MIPS simply by accessing a variable. We need to count through every character until we reach the null character. An example of counting through each character in a high level language follows below: for(int i = 0; str[i] != 0; i++) length++; To perform this loop in MIPS, the code follows:

MIPS version # Assume the memory address of the string is $t1 and the # counter is $t2. # Perform loop operations. lb $t3, 0($t1) #load the first byte into a register whileloop: beq $t0, $zero, endwhile lb $t3, 0($t1) #load the next byte addi $t1, $t1, 1 #increment the counter and address addi $t2, $t2, 1 b whileloop endwhile:

More Examples We will also look at how to print every other character in a string assuming we are given the length and the address of the string. To perform this operation in C, we may use a for loop as follows: for(int i = 0; i < length; i += 2) printf("%c", str[i]); Let's assume our counter uses $t0 and the address of the string is $t1. Assume these values are valid. Then our loop looks as follows:

MIPS version for: bge $t0, $t2, endfor #assume the size of the string is in $t2 lb $t3, 0($t1) move $a0, $t3 #print the character from the even index li $v0, 11 syscall addi $t0, $t0, 2 #add 2 to the address and counter addi $t1, $t1, 2 b for endfor: Notice that we add two to both our address and counter to step through the loop and step through the addresses.