1 Review Chpt 2 and 3 Five components of a computer Input Output Memory Arithmetic & Logic Unit (ALU) Control Two types of information Data and instruction.

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

Lecture 5: MIPS Instruction Set
1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 2: Data types and addressing modes dr.ir. A.C. Verschueren.
1 Lecture 3: Instruction Set Architecture ISA types, register usage, memory addressing, endian and alignment, quantitative evaluation.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 5: Data Transfer Instructions / Control Flow Instructions Partially adapted from Computer.
Arithmetic in Computers Chapter 4 Arithmetic in Computers2 Outline Data representation integers Unsigned integers Signed integers Floating-points.
10/9: Lecture Topics Starting a Program Exercise 3.2 from H+P Review of Assembly Language RISC vs. CISC.
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.
The University of Adelaide, School of Computer Science
Assembly Language Working with the CPU.
Advanced Topics Object-Oriented Programming Using C++ Second Edition 13.
TK 2633 Microprocessor & Interfacing Lecture 3: Introduction to 8085 Assembly Language Programming (2) 1 Prepared By: Associate Prof. Dr Masri Ayob.
CIS429/529 ISA - 1 Instruction Set Architectures Classification Addressing Modes Types of Instructions Encoding Instructions MIPS64 Instruction Set.
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
S. Barua – CPSC 440 CHAPTER 2 INSTRUCTIONS: LANGUAGE OF THE COMPUTER Goals – To get familiar with.
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
8 November Forms and JavaScript. Types of Inputs Radio Buttons (select one of a list) Checkbox (select as many as wanted) Text inputs (user types text)
Informationsteknologi Friday, October 19, 2007Computer Architecture I - Class 61 Today’s class Floating point numbers Computer systems organization.
MIPS Instruction Set Advantages
Lecture 18 Last Lecture Today’s Topic Instruction formats
Computer Arithmetic. Instruction Formats Layout of bits in an instruction Includes opcode Includes (implicit or explicit) operand(s) Usually more than.
Lesson 2 — How Does A Computer Process Data?
Machine Instruction Characteristics
IT253: Computer Organization
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
Data Representation and Storage Lecture 5. Representations A number value can be represented in many ways: 5 Five V IIIII Cinq Hold up my hand.
Number Systems Spring Semester 2013Programming and Data Structure1.
Computer Systems Organization CS 1428 Foundations of Computer Science.
Implementation of a Stored Program Computer ITCS 3181 Logic and Computer Systems 2014 B. Wilkinson Slides2.ppt Modification date: Oct 16,
Memory and Addressing How and Where Information is Stored.
Registers and MAL Lecture 12. The MAL Architecture MAL is a load/store architecture. MAL supports only those addressing modes supported by the MIPS RISC.
Chapter 10 The Assembly Process. What Assemblers Do Translates assembly language into machine code. Assigns addresses to all symbolic labels (variables.
Execution of an instruction
Informationsteknologi Friday, September 28, 2007Computer Architecture I - Class 21 Today’s class More assembly language programming.
IFT 201: Unit 1 Lecture 1.3: Processor Architecture-3
A summary of TOY. 4 Main Components Data Processor Control Processor Memory Input/Output Device.
Computer Architecture EKT 422
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
Computer Organization Rabie A. Ramadan Lecture 3.
Chapter 2 — Instructions: Language of the Computer — 1 Conditional Operations Branch to a labeled instruction if a condition is true – Otherwise, continue.
Data Representation. How is data stored on a computer? Registers, main memory, etc. consists of grids of transistors Transistors are in one of two states,
Arrays in MIPS Assembly Computer Organization and Assembly Language: Module 6.
Computer Organization Instructions Language of The Computer (MIPS) 2.
Instruction Sets. Instruction set It is a list of all instructions that a processor can execute. It is a list of all instructions that a processor can.
CS 125 Lecture 3 Martin van Bommel. Overflow In 16-bit two’s complement, what happens if we add =
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Computer Architecture. Instruction Set “The collection of different instructions that the processor can execute it”. Usually represented by assembly codes,
Computer Architecture & Operations I
Programming and Data Structure
Computer Architecture Instruction Set Architecture
MIPS Instruction Set Advantages
CS2100 Computer Organisation
Number Representation
Chapter 3 Data Storage.
Lecture 4: MIPS Instruction Set
Microcomputer Programming
Lecture 4: MIPS Instruction Set
CS170 Computer Organization and Architecture I
Arithmetic Logical Unit
Review.
ECEG-3202 Computer Architecture and Organization
Chapter 3 DataStorage Foundations of Computer Science ã Cengage Learning.
Computer Instructions
ECEG-3202 Computer Architecture and Organization
MIPS Assembly.
MIPS assembly.
Computer Organization and Assembly Language
MIPS instructions.
Chapter 10 Instruction Sets: Characteristics and Functions
Presentation transcript:

1 Review Chpt 2 and 3 Five components of a computer Input Output Memory Arithmetic & Logic Unit (ALU) Control Two types of information Data and instruction

2 Think of a Calculator Components in a calculator Input Output Memory ALU One type of information Data

3 Memory in Calculator One register R, which is implicit Its content is shown at the LCD panel Arithmetic operations are performed on R One memory M, which is explicit Its content is not shown. Arithmetic operation on M is limited M is additional storage in case R is not enough Copy data from R to M is done by MS Copy data from M to R is done by MR

4 Memory in Computer (MIPS) More registers 32 integer registers: $0 to $31 32 floating-point registers: $f0 to $f31 More memory 4 Giga Byte (GB) memory, organized as 1 Gita Word A word is 32 bits (b), a Byte (B) is 8 bits A unique address is designated for each memory byte 1K=1024=2 10, 1M=1024K=2 20, 1G=1024M=2 30

5 Examples Which one can store more information: a 128MB memory card or a half Gb memory chip? How many times more data can a 40GB hard disk store than a 256KB memory?

6 Memory Address FFFFFFFC FFFFFFF

7 Example: Memory content chara:.word 0x # assume starting mem 0 msg1:.asciiz “ab01cd” msg2:.ascii “ab” value:.word ?? F C

8 Data and Instruction Memory contains data and instruction The content itself does not tell if it is data or instruction Each instruction takes one word, and instruction address must be a word address

9 Data Encoding ASCII code (American Standard Code for Information Interchange) Total 128 characters, including digits (0-9) alphabets (a-z, A-Z) math (+, -, *, /, >, <, =, (, ), {, }, [, ], %) punctuations (!,,,., ?, :, ;, ‘, “, `,,) special #, $, ^, &, ~, _, |, \) control (back space, tab, line return, null)

10 Data Encoding Unicode (universal encoding) Capable of expressing most languages in the world TextASCIIUTF-8UTF-16 big gro  f ?? f c3 9f f 00df

11 Data Encoding Fixed point integer Single precision floating point Double precision floating point Question: Which format is most efficient in expressing a number, say ? How about ? ASCII character string Fixed point Floating point

12 Example on Numbers What is the following hexadecimal? 8D as binary: D as integer (in decimal): -(2^27+2^26+2^24+2^21) 8D as floating-point (in decimal): (-1) 2^{26-127}*( )= 8D as instruction: lw $8 0($9)

13 Word v.s. Byte Memory can be addressed either as words, each 32 bits, or as bytes, each 8 bits Whether an address is word address or byte address depends on the instruction lw $a1, 0($zero)# $a1 = lw $a1, 2($a2)# assume $a2=6 # $a1 = lbu $a1, -7($a2)# assume $a2=12 # $a1 =

14 ALU In a calculator, ALU performs operation between R and the new number typed on key pad 12+ enter 12 into R and operation is + 3= enter 3, and perform addition with R In a computer, ALU performs more complex operations between registers

15 Example Convert temperature from Fahrenheit in $f0 to Celsius: C=(5/9)*(F-32) Assume 5.0 is in $f16, 9.0 is in $f17, and 32.0 is in $f18 div.s $f16, $f16, $f17#.s is single precision sub.s $f0, $f0, $f18 mul.s $f0, $f0, $f16 Puzzle: How to swap values in $a1 and $a2 without using additional register?

16 Fixed Point Mult/Div Assume F temperature is in $a0, store C temperature result in $a1 addi$a1, $a0, -32# $a1 = F-32 addi$t0, $zero, 5# $t0 = 5 mult$a1, $t0# mult first reduces error mflo$a1# $a1 = (F-32)*5 addi$t0, $zero, 9# $t0 = 9 div$a1, $t0 mflo$a1

17 IEEE 754 Standard Exception Normal case e=1 to 254: (-1) S * 2 e-127 * 1.M Special cases: Exponent=0, mantissa=0: 0 Exponent=0, mantissa  0: denormalized (-1) S * * 0.M Exponent=255, mantissa=0:  Infty Exponent=255, mantissa  0: NaN

18 Control In a calculator, human controls the operation at each step In a computer, control follows from the instruction 1. Program Counter (PC) points to the first instruction to be executed 2. Execute the instruction pointed by PC 3. PC=PC+4, go to 2 If there is branch instruction, PC is modified

19 Exercise Count the number of 1’s in $a0 and store result in $s0 or $s0, $zero, $zero# $s0=0 addi $t0, $zero, 1# $t0= loop:beq $t0, $zero, exit# if $t0=0, exit and $t1, $a0, $t0# check one bit sll $t0, $t0, 1# shift $t0 left 1 bit beq $t1, $zero, loop addi $s0, $s0, 1# found a 1 j loop exit:

20 Five Address Modes (p. 101) Address Mode tells where to find the data or branch address Immediate addressing It is rather “immediate” than “addressing” since the data is included in the instruction For example, addi $a1, $a1, 100 Register addressing Data address is register number For example, add $a1, $a1, $a0

21 Five Addressing Mode (cont’d) Base (or displacement) addressing Data address is base (register content) plus displacement For example, lw $a1, 12($a0)

22 Five Addressing Mode (cont’d) The last two modes are for branch only. Address is instruction address. PC-relative addressing Branch address is PC+4+offset*4 For example, beq $a1, $zero, 100 Pseudo-direct addressing Branch address is 26 bits in instruction concatenated with top 4 bits of PC For example, j 10000

23 Addressing Mode Example C program, assume i and k correspond to $s3 and $s5, and base address of array a is in $s6: while (a[i] == k) i = i + 1; MIPS assembly code loop:sll $t1, $s3, 2# $t1 = i*4 add $t1, $t1, $s6# $t1 = addr of a[i] lw $t0, 0($t1)# $t0 = a[i] bne $t0, $s5, exit# if a[i] != k, exit addi $s3, $s3, 1# i = i+1 j loop# go to loop

24 Addressing Mode Example loop:sll $t1, $s3, 2# $t1 = i*4 add $t1, $t1, $s6# $t1 = addr of a[i] lw $t0, 0($t1)# $t0 = a[i] bne $t0, $s5, exit# if a[i] != k, exit addi $s3, $s3, 1# i = i+1 j loop# go to loop exit FFFF0004 FFFF0008 FFFF000C FFFF0010 FFFF0014 FFFF0018

25 Homework 2, due Friday 2.21, , 3.42

26 Exercise 2.21 Write a subroutine convert to convert an ASCII decimal string to an integer. You can expect register $a0 to hold the address of a null-terminated string containing some combination of the digits 0 through 9. Your program should compute the integer value equivalent to this string of digits, then place the number in register $v0. If a non-digit character, including “-” or “.”, appears anywhere in the string, your program should stop with the value –1 in register $v0. For example, if register $a0 points to a sequence of three character 50 ten, 52 ten, 0 ten (the null-terminated string “24”), then when the program stops, register $v0 should contain the value 24 ten.

27 Exercise 2.36 Consider the following fragment of C code: for (i=0; i<=100; i=i+1) a[i] = b[i] +c; Assume that a and b are arrays of words and the base address of a is in $a0 and the base address of b is in $a1. Register $t0 is associated with variable i and register $s0 with c. Write the code for MIPS. How many instructions are executed during the running of this code? How many memory data references will be made during execution?

28 Chapter 4 Performance What is performance? Response time: The time between start and completion of the task. (unit is time, say sec) Throughput: the total amount of work done at a given time. (unit is jobs/sec) Do the following changes to a computer system increase/decrease performance? Replacing the processor by a faster one Adding additional processors to a multi-processor system, such as google search engine