Computer Architecture Lecture 2 Instruction Set Principles.

Slides:



Advertisements
Similar presentations
1 Lecture 3: MIPS Instruction Set Today’s topic:  More MIPS instructions  Procedure call/return Reminder: Assignment 1 is on the class web-page (due.
Advertisements

CENG 311 Decisions in C/Assembly Language
Goal: Write Programs in Assembly
4.
Lecture 5: MIPS Instruction Set
MIPS assembly. Review  Lat lecture, we learnt  addi,  and, andi, or, ori, xor, xori, nor,  beq, j, bne  An array is stored sequentially in the memory.
Branches Two branch instructions:
The University of Adelaide, School of Computer Science
Lecture 20: 11/12/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Lecture 9: MIPS Instruction Set
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /15/2013 Lecture 11: MIPS-Conditional Instructions Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER.
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.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 5: Data Transfer Instructions / Control Flow Instructions Partially adapted from Computer.
1 Lecture 4: Procedure Calls Today’s topics:  Procedure calls  Large constants  The compilation process Reminder: Assignment 1 is due on Thursday.
Lecture 6: MIPS Instruction Set Today’s topic –Control instructions –Procedure call/return 1.
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
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.
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.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /17/2013 Lecture 12: Procedures Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE CENTRAL.
Ch. 8 Functions.
CS1104 – Computer Organization PART 2: Computer Architecture Lecture 4 Assembly Language Programming 2.
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.
Chap.2: Instructions: Language of the computer Jen-Chang Liu, Spring 2006 Adapted from
Computer Architecture Lecture 3 C and Assembly. Intro to Assembly Language MIPS and Intel Variables and Constants int count = 10, I, j, k; count.word.
MIPS Assembly Language I Computer Architecture CPSC 321 Andreas Klappenecker.
Intro to Computer Architecture
ECE 232 L5 Assembl.1 Adapted from Patterson 97 ©UCBCopyright 1998 Morgan Kaufmann Publishers ECE 232 Hardware Organization and Design Lecture 5 MIPS Assembly.
Data Transfer & Decisions I (1) Fall 2005 Lecture 3: MIPS Assembly language Decisions I.
CS 300 – Lecture 6 Intro to Computer Architecture / Assembly Language Instructions.
9/29: Lecture Topics Memory –Addressing (naming) –Address space sizing Data transfer instructions –load/store on arrays on arrays with variable indices.
Lecture 7: MIPS Instruction Set Today’s topic –Procedure call/return –Large constants Reminders –Homework #2 posted, due 9/17/
Character Data and 32-bit Constants (Lecture #20) ECE 445 – Computer Organization The slides included herein were taken from the materials accompanying.
Lecture 4: MIPS Instruction Set
Lecture 10: MIPS Simulator Today’s topic –SPIM Simulator Readings –Appendix B 1.
Computer Architecture CSE 3322 Lecture 4 crystal.uta.edu/~jpatters/cse3322 Assignments due 9/15: 3.7, 3.9, 3.11.
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.
Computer Architecture CSE 3322 Lecture 3 Assignment: 2.4.1, 2.4.4, 2.6.1, , Due 2/3/09 Read 2.8.
MS108 Computer System I Lecture 3 ISA Prof. Xiaoyao Liang 2015/3/13 1.
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.
Computer Architecture CSE 3322 Lecture 4 Assignment: 2.4.1, 2.4.4, 2.6.1, , Due 2/10/09
Chapter 2 — Instructions: Language of the Computer — 1 Conditional Operations Branch to a labeled instruction if a condition is true – Otherwise, continue.
DR. SIMING LIU SPRING 2016 COMPUTER SCIENCE AND ENGINEERING UNIVERSITY OF NEVADA, RENO Session 11 Conditional Operations.
Control Structures Computer Organization I 1 October 2009 © McQuain, Feng & Ribbens Conditional Control Structure if ( i < j ) goto A; else.
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Lecture 5: Procedure Calls
CS2100 Computer Organisation
A Memory Aliased Instruction Set Architecture
Lecture 4: MIPS Instruction Set
Computer Architecture & Operations I
Decision Making.
Procedures (Functions)
Assembly Programming using MIPS R3000 CPU
The University of Adelaide, School of Computer Science
CSCI206 - Computer Organization & Programming
Lecture 4: MIPS Instruction Set
MIPS coding.
The University of Adelaide, School of Computer Science
Assembly Programming using MIPS R3000 CPU
Generalities for Assembly Language
MIPS Assembly Language Programming Computer Architecture
9/27: Lecture Topics Memory Data transfer instructions
Conditional Branching (beq)
MIPS Assembly.
Presentation transcript:

Computer Architecture Lecture 2 Instruction Set Principles

Intro to Assembly Language MIPS and Intel Variables and Constants int count = 10, I, j, k; count.word 10 i.word j.word Count DD10 iDD? jDD?

Byte size variables char sum = 1, total= 5; char uni[10] =“university”; sum.byte 1 total.byte 5 uni.byte “u”,”n”, “i” etc; sum db 1 total db 5 uni db “u”,”n”, “i” etc;

Strings string str (“hello world”); str.asciiz “hello world” str db “hello world”

Arrays int age[100]; age.word 0:100 ; 100 words initialized to zero age dw 100 dup(0); 100 words initialized to zero

Assignment count = count +1; la R1, count # (load address works in spim) #R1 has address of count lw R2, 0(R1)# R2 has the value of count addi R2, R2, 1# Increment sw R2, 0(R1)# Save count, if need be

Another Example i = age[20] +age[0] + count; la R3, age#R3 has base address of age; lw R4, 80[R3]#20 * 4 = 80, R4 = age[20] lw R5, 0(R3)#R5 = age[0] add R4, R4, R5# add R4, R4, R2#R2 had value of count above

Control count = 0; while (count < 21) { age[count] = age[count+1]; count = count+1; } addiR2, R0, 0; R2 = count = 0 lable1: mul R6, R2, 4 ; R6 has address of ; count th element add R6, R6, R4:R2= count, R4 = age ;R6 = address of count[age] lw R7, 4(R6);R7 = age[count+1] sw R7, 0(r6); age[count] = R7 addi R2, R2, 1; Count = count +1; slti R8, R2, 21; ;R8 = 1 if count<21 bnez R8, label1

For Statement Total = 0; For (i= 0; i<count; i ++) {total = age[i] + total;} la R1, age #R1 has address of count lw R2, 0(R1)# R2 has the value of count addi R5, R0, 0# i = 0 ; R5 is i addi R15, R0, 0# total = 0 ; R15 is total Xy:sltR11,R5,R10# check R5 is R5 < R10 (R10 is count) beR11, R0, lable# loop until mul R6, R5, 4 # R6 has address of i th element of age add R6, R6, R4# R4 = address of age lwR20, 0(R6)#R20 = age[i] addR15, R15, R20# total = total + age[i] swR15, 0(R22)# R22 is address of total addiR5,R5,1# i = i+1; bXy:# Unconditional branch Lanbl:

IF … then If (count == max) I = 5; else I = 20; #assume R4 has the value of count, R7 has value of MAX and I is R5 bne R4, R7, else addiR5, R0, 5 bexit else:addiR5, R0, 20 exit:

Classifying Instruction Set Architectures Stack Register- Register Register – Memory Accumulator Memory – Memory