CSCI 136 Lab 1 Outline Go through the CD attached to the textbook. Homework Hints 135 Review.

Slides:



Advertisements
Similar presentations
B261 Systems Architecture
Advertisements

Integer Arithmetic: Multiply, Divide, and Bitwise Operations
CS/COE0447 Computer Organization & Assembly Language
Microprocessors General Features To be Examined For Each Chip Jan 24 th, 2002.
Lecture - 2 Number systems and computer data formats
CS2422 Assembly Language & System Programming September 19, 2006.
CS 61C L02 Number Representation (1) Garcia, Spring 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c CS61C.
COMP3221: Microprocessors and Embedded Systems--Lecture 1 1 COMP3221: Microprocessors and Embedded Systems Lecture 3: Number Systems (I)
COMP3221 lec05-numbers-I.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lecture 5: Number Systems – I
CS 61C L02 Number Representation (1)Harvey / Wawrzynek Fall 2003 © UCB 8/27/2003  Brian Harvey ( John Wawrzynek  (Warznek) (
Data Representation Computer Organization &
Data Representation COE 205
Assembly Language and Computer Architecture Using C++ and Java
The slides are modified from Dan Garcia,
Introduction to Programming with Java, for Beginners
CS 61C L02 Number Representation (1) Garcia, Spring 2004 © UCB Lecturer PSOE Dan Garcia inst.eecs.berkeley.edu/~cs61c CS61C.
Assembly Language and Computer Architecture Using C++ and Java
Lecture 5 Sept 14 Goals: Chapter 2 continued MIPS assembly language instruction formats translating c into MIPS - examples.
Number Representation (1) Fall 2005 Lecture 12: Number Representation Integers and Computer Arithmetic.
1  1998 Morgan Kaufmann Publishers Chapter Four Arithmetic for Computers.
CEG 320/520: Computer Organization and Assembly Language Programming1 CEG 320/520 Computer Organization and Assembly Language Programming.
+ CS 325: CS Hardware and Software Organization and Architecture Integers and Arithmetic.
Lecture 2: Number Representation
Data Representation in Computers
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
CENG 311 Machine Representation/Numbers
Lecture 5.
Computers Organization & Assembly Language
CMPE 325 Computer Architecture II Cem Ergün Eastern Mediterranean University Integer Representation and the ALU.
CSU0014 Assembly Languages Homepage: Textbook: Kip R. Irvine, Assembly Language for Intel-Based Computers,
1 Modified from  Modified from 1998 Morgan Kaufmann Publishers Chapter Three: Arithmetic for Computers citation and following credit line is included:
Data Representation - Part I. Representing Numbers Choosing an appropriate representation is a critical decision a computer designer has to make The chosen.
EX_01.1/46 Numeric Systems. EX_01.2/46 Overview Numeric systems – general, Binary numbers, Octal numbers, Hexadecimal system, Data units, ASCII code,
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CS-334: Computer.
Lecture Objectives: 1)Define the terms least significant bit and most significant bit. 2)Explain how unsigned integer numbers are represented in memory.
The Hexadecimal Number System and Memory Addressing ISAT 121.
CSCI 136 Lab 1: 135 Review.
Chapter 19 Number Systems. Irvine, Kip R. Assembly Language for Intel-Based Computers, Translating Languages English: Display the sum of A times.
Chapter 10 The Assembly Process. What Assemblers Do Translates assembly language into machine code. Assigns addresses to all symbolic labels (variables.
Chapter 2-2 Assembly Instructions Number Systems Number Systems Assembly Instructions Assembly Instructions Branch Branch Next Lecture Next Lecture  Addressing.
1 COMS 161 Introduction to Computing Title: The Digital Domain Date: September 6, 2004 Lecture Number: 6.
Computer Architecture and Organization
Computer Architecture EKT 422
 Lecture 2 Processor Organization  Control needs to have the  Ability to fetch instructions from memory  Logic and means to control instruction sequencing.
Cs641 pointers/numbers.1 Overview °Stack and the Heap °malloc() and free() °Pointers °numbers in binary.
Chapter 10 Instruction Sets: Characteristics and Functions Felipe Navarro Luis Gomez Collin Brown.
1 Lecture 7: MARS, Computer Arithmetic Today’s topics:  MARS intro  Numerical representations  Addition and subtraction.
Chapter 2 — Instructions: Language of the Computer — 1 Memory Operands Main memory used for composite data – Arrays, structures, dynamic data To apply.
What is a program? A sequence of steps
Group # 3 Jorge Chavez Henry Diaz Janty Ghazi German Montenegro.
EE204 L03-ALUHina Anwar Khan EE204 Computer Architecture Lecture 03- ALU.
Bits, Data Types, and Operations
Lec 3: Data Representation
Lecture 7: MARS, Computer Arithmetic
Data Representation Binary Numbers Binary Addition
Morgan Kaufmann Publishers
March 2006 Saeid Nooshabadi
CSCI206 - Computer Organization & Programming
Computer Architecture & Operations I
ECEG-3202 Computer Architecture and Organization
COMS 161 Introduction to Computing
Computer Architecture
ECEG-3202 Computer Architecture and Organization
UCSD ECE 111 Prof. Farinaz Koushanfar Fall 2018
Review In last lecture, done with unsigned and signed number representation. Introduced how to represent real numbers in float format.
MIPS Arithmetic and Logic Instructions
Chapter 10 Instruction Sets: Characteristics and Functions
Presentation transcript:

CSCI 136 Lab 1

Outline Go through the CD attached to the textbook. Homework Hints 135 Review

Prob 1.46 Magnetic disk: –On average, needs ½ revolution time for the disk to spin under the read/write head. For 7200 RPM, what is 1 revolution time? How about RPM?

Prob 1.51 Cost per wafer: $ wafer produces 1500 dies, where 50% are valid dies. –How many valid dies per wafer? –Cost per valid die? Chip = 1 die + package + test Cost for package + test : $10 Test yield: 90% –Cost per valid chip? Retail Price = Cost per valid chip * (1 + 40%). Invest: $500,000 –How many valid chips have to be sold to break even?

Prob 1.52 CISC vs. RISC –CISC needs fewer instructions to perform a task compared with RISC. –RISC instructions take less time. For a certain task –P CISC instructions vs. 2P RISC instructions –8T ns per CISC instr. vs. 2T ns per RISC instr. Which one is better?

Prob 1.54 Multiplication operation: 10 ns Subtraction operation: 1 ns d = a*b – a*c –How long time? How to optimize the equation to take less time?

Some Requirements Make the homework solutions clear –Handwriting & Content Prepare before coming the lab –Read the homework problems To be added…

Decimal Numbers: Base 10 Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Example: 3271 = (3x10 3 ) + (2x10 2 ) + (7x10 1 ) + (1x10 0 ) The following 8 slides are from UCB CS61C

Numbers: positional notation Number Base B  B symbols per digit: –Base 10 (Decimal):0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Base 2 (Binary):0, 1 Number representation: –d 31 d d 1 d 0 is a 32 digit number –value = d 31  B 31 + d 30  B d 1  B 1 + d 0  B 0 Binary:0,1 (In binary digits called “bits”) –0b11010 = 1      2 0 = = 26 –Here 5 digit binary # turns into a 2 digit decimal # –Can we find a base that converts to binary easily? #s often written 0b…

Hexadecimal Numbers: Base 16 Hexadecimal: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F –Normal digits + 6 more from the alphabet –In C, written as 0x… (e.g., 0xFAB5) Conversion: Binary  Hex –1 hex digit represents 16 decimal values –4 binary digits represent 16 decimal values  1 hex digit replaces 4 binary digits One hex digit is a “nibble”. Two is a “byte” Example: – (binary) = 0x_____ ?

Decimal vs. Hexadecimal vs. Binary A B C D E F1111 MEMORIZE! Examples: (binary) = 0xAC (binary) = (binary) = 0x17 0x3F9 = (binary) How do we convert between hex and Decimal?

Which base do we use? Decimal: great for humans, especially when doing arithmetic Hex: if human looking at long strings of binary numbers, its much easier to convert to hex and look 4 bits/symbol –Terrible for arithmetic on paper Binary: what computers use; you will learn how computers do +, -, *, / –To a computer, numbers always binary –Regardless of how number is written: 32 ten == == 0x20 == == 0b –Use subscripts “ten”, “hex”, “two” in book, slides when might be confusing

BIG IDEA: Bits can represent anything!! Characters? –26 letters  5 bits (2 5 = 32) –upper/lower case + punctuation  7 bits (in 8) (“ASCII”) –standard code to cover all the world’s languages  8,16,32 bits (“Unicode”) Logical values? –0  False, 1  True colors ? Ex: locations / addresses? commands? MEMORIZE: N bits  at most 2 N things Red (100)Green (010)Blue (001)

How to Represent Negative Numbers? So far, unsigned numbers Obvious solution: define leftmost bit to be sign! –0  +, 1  - –Rest of bits can be numerical value of number Representation called sign and magnitude MIPS uses 32-bit integers. +1 ten would be: And - 1 ten in sign and magnitude would be:

Shortcomings of sign and magnitude? Arithmetic circuit complicated –Special steps depending whether signs are the same or not Also, two zeros – 0x = +0 ten – 0x = -0 ten –What would two 0s mean for programming? Therefore sign and magnitude abandoned

2’s Complement Numbers As with sign and magnitude, leading 0s  positive, leading 1s  negative – xxx is ≥ 0, xxx is < 0 –except 1…1111 is -1, not -0 (as in sign & mag.) To get negative number from a positive.. Invert all digits and add 1. To get a positive number from a negative… Invert all digits and add 1. Assume 8 bit word. What is -57 in 2’s complement notation?

2’s Complement Number “line”: N = 5 2 N-1 non- negatives 2 N-1 negatives one zero how many positives?

Sign Extension Sign extension can be used when you shift a register right… the sign bit is repeated to keep a negative number negative… This is referred to as “Arithmetic” variety of shift If the sign bit isn’t extended.. (i.e. empty spots filled with 0 s) then the shift is called “Logical” variety of shift

Assume 8 bit words… What is result of logical right shifting -12 by 2? assembly: srl (shift right logical) srlv (shift right logical variable) What is result of arithmetic right shift -12 by 2? assembly: sra (shift right arithmetic) srav (shift right arithmetic variable) What is result of rotate right -12 by 2? assembly: ror (rotate right) What is the assembly code to do this?

What is result of rotating left -12 by 2? assembly: rol (rotate left) What is the result of logical shift left -12 by 2? assembly: sll (shift left logical) sllv (shift left logical variable) What is the assembly code to do this? Why isn’t there a sla (shift left arithmetic) assembly instruction?

Byte Ordering Assume 32 bit word: Big Endian vs. Little Endian In a big-endian system, the most significant value in the sequence is stored at the lowest storage address (i.e., first). In a little-endian system, the least significant value in the sequence is stored first Address Big-Endian representation of 1025 Little-Endian representation of

Byte Ordering Computer designers can’t seem to agree on whether to use Big Endian or Little Endian. Neither design is really superior to the other. What kind of Endian are Intel PCs? What kind of Endian are Macs? Sun SPARC Stations can be set in either mode… (but Solaris OS requires Big Endian). Most of the time.. you probably won’t notice Endianness. But SPIM simulator uses the “Endianness” of the machine you run it on!

Load Immediate (li) What does the following instruction do? li $t0, 0x What does the following sequence of instructions do? lui $t0, 4004 ori $t0, $t0, 4005

li (load immediate) instruction is really “pseudocode” When the assembler sees an li instruction it substitutes: lui (load upper immediate) followed by an ori (or immediate) In the place of the li (load immediate)

Time Units How long is a microsecond? How long is a nanosecond? How long is a picosecond? If a clock runs at 450MHZ how long is a clock cycle? If a clock runs at 1.2GHZ how long is clock cycle?

Cycles Per Instruction Different Instructions may take different numbers of clock cycles to execute. CPI (Cycles Per Instruction) refers to number of clock cycles an instruction takes in a design What is average CPI of the following 600 MHZ machine? What is the MIPS rating? Instruction ClassCPIFreq Load Word831% Store Word721% ALU (R format)641% Branch55% Jump22%

PCSPIM A software simulator for the MIPS32 architecture. Load assembly file. Run in the software.

.text.globl main main: move $t6, $0 move $t7, $0 loop: addu $t7, $t7, $t6 addu $t6, $t6, 1 ble $t6, 100, loop li $v0, 4 la $a0, str syscall li $v0, 1 move $a0, $t7 syscall.data str:.asciiz "The sum from is "