MIPS instructions.

Slides:



Advertisements
Similar presentations
Arrays First step is to reserve sufficient space for the array.
Advertisements

The University of Adelaide, School of Computer Science
CS 136 Lab 2 MIPS ISA SPIM. Prob 2.30 sll $a2, $a2, 2 sll $a3, $a3, 2 add $v0, $zero, $zero add $t0, $zero, $zero outer:add $t4, $a0, $t0 lw $t4, 0($t4)
CDA 3100 Recitation Week 8. Question 1.data A:.word 21,3,2,9,100,22,6,15,33,90.text.globl main main: la $a0, A li $a1, 17 li $a2, 10 jal funct li $v0,
CDA 3100 Recitation Week 15. What does the function f1 do:.data A:.word 10,21,45,8,100,15,29,12,3,19 B:.word 2,5,33,5,20,1,53,52,5,5 C:.word 6,8,5,4,5,22,53,12,33,89.text.globl.
MIPS Assembly Language CPSC 321 Computer Architecture Andreas Klappenecker.
1 Procedure Calls, Linking & Launching Applications Lecture 15 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.
Chapter 2 — Instructions: Language of the Computer — 1 Branching Far Away If branch target is too far to encode with 16-bit offset, assembler rewrites.
Solution 2nd Exam.
Assembly Code Example Selection Sort.
SPRING 2015 QtSpim Demo & Tutorial. 2 By DGP Outline How to write your own MIPS assembly language program How to use QtSpim simulator.
The University of Adelaide, School of Computer Science
SPIM and MIPS programming
Syscall in MIPS Xinhui Hu Yuan Wang.
MIPS Function Continued
Fibonacci with Loop int fib1(int i) { int f1 = 1; int f2 = 1; int f3;
Assembly Language Working with the CPU.
.text fact: addiu $sp, $sp, -32 sw $ra, 20($sp) sw $fp, 16($sp) addiu $fp, $sp, 28 sw $a0, 0($fp) bgtz $a0, L2 li $v0, 1 b suffix L2: addi $a0, $a0,
Writing an Embedded Controller. It usually consists of two parts – Initialization – A main loop Experience: – The main loop usually has to deal with many.
Solution to Problem Recitation #1 (Week 2) ECEN350 Prof. Choi.
MIPS Coding. Exercise – the bubble sort 5/8/2015week04-3.ppt2.
MIPS Assembly Language I Computer Architecture CPSC 321 Andreas Klappenecker.
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.
1 Branches and Procedure Calls Lecture 14 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.
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.
MIPS Coding. Exercise – the bubble sort 7/9/2016week04-3.ppt2.
MIPS Assembly Language Programming
Function Calls in MIPS To call a function: jal func
Switch Statement Pre-requisites: 1D array addressing Updated 7/11/2013.
MIPS Assembly Language Programming
CS2100 Computer Organization
Arrays First step is to reserve sufficient space for the array.
MIPS Procedures.
MIPS Coding Continued.
Lecture 4: MIPS Instruction Set
Computer Architecture & Operations I
Pseudo instructions.
The University of Adelaide, School of Computer Science
MIPS coding.
Final Review.
SPIM Syscalls.
MIPS Procedures.
Review.
Assembler Directives Example program: .data # DATA segment city: .asciiz “Seattle” .align 2 num: .word 2210, 2341, 26, 0x022ec,
Addressing in Jumps jump j Label go to Label op address 2 address
MIPS Functions.
Logical and Decision Operations
MIPS coding.
MIPS Functions.
Pseudo instructions.
Review.
MIPS Functions.
Logical and Decision Operations
MIPS coding.
MIPS functions.
MIPS Procedures.
Review.
MIPS Coding.
MIPS function continued
MIPS Functions.
MIPS Coding.
MIPS I/O and Interrupt.
Review.
MIPS Coding Continued.
MIPS coding.
MIPS Functions.
MIPS function continued
MIPS Functions.
Conditional Branching (beq)
Presentation transcript:

MIPS instructions

Writing a bubble sort code 8/6/2018 week04-3.ppt

The code we wrote in the class .data array: .word 12, 34, 67, 1, 45, 90, 11, 33, 67, 19 msg_done: .asciiz "bubble sort done\n" .text .globl main main: la $s7, array li $s0, 0 #i li $s6, 9 #N-1 li $s1, 0 #j loop: sll $t7, $s1, 2 add $t7, $s7, $t7 # got the address of A[j] lw $t0, 0($t7) #$t0 is A[j] lw $t1, 4($t7) #$t1 is A[j+1] sub $t2, $t0, $t1 bgtz $t2, noordoneswap sw $t1, 0($t7) #$t0 is A[j] sw $t0, 4($t7) #$t0 is A[j+1] noordoneswap: addi $s1, $s1, 1 sub $s5, $s6, $s0 #$s3 is N-i-1 bne $s1, $s5, loop addi $s0, $s0, 1 bne $s0, $s6, loop done: li $v0,4 la $a0,msg_done syscall jr $ra