Monday, January 14 Homework #1 is posted on the website Homework #1 is posted on the website Due before class, Jan. 16 Due before class, Jan. 16.

Slides:



Advertisements
Similar presentations
Lecture - 2 Number systems and computer data formats
Advertisements

Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3: IT Students.
Floating Point Numbers
Digital Fundamentals Floyd Chapter 2 Tenth Edition
Assembly Language and Computer Architecture Using C++ and Java
Assembly Language and Computer Architecture Using C++ and Java
S. Barua – CPSC 240 CHAPTER 2 BITS, DATA TYPES, & OPERATIONS Topics to be covered are Number systems.
Number Systems Lecture 02.
Binary Representation and Computer Arithmetic
Dr. Bernard Chen Ph.D. University of Central Arkansas
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Fundamentals Tenth Edition Floyd.
Simple Data Type Representation and conversion of numbers
Data Representation – Binary Numbers
Computers Organization & Assembly Language
Binary Real Numbers. Introduction Computers must be able to represent real numbers (numbers w/ fractions) Two different ways:  Fixed-point  Floating-point.
Information Representation (Level ISA3) Floating point numbers.
Computer Organization and Architecture Computer Arithmetic Chapter 9.
Computer Arithmetic Nizamettin AYDIN
Computer Arithmetic. Instruction Formats Layout of bits in an instruction Includes opcode Includes (implicit or explicit) operand(s) Usually more than.
1 CS/COE0447 Computer Organization & Assembly Language Chapter 3.
Computer Arithmetic.
1 Digital Technology and Computer Fundamentals Chapter 1 Data Representation and Numbering Systems.
NUMBER REPRESENTATION CHAPTER 3 – part 3. ONE’S COMPLEMENT REPRESENTATION CHAPTER 3 – part 3.
IT253: Computer Organization
Computer Architecture
Topic 2 – Introduction to Computer Codes. Computer Codes A code is a systematic use of a given set of symbols for representing information. As an example,
1 Digital Systems and Binary Numbers EE 208 – Logic Design Chapter 1 Sohaib Majzoub.
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
ECEN2102 Digital Logic Design Lecture 1 Numbers Systems Abdullah Said Alkalbani University of Buraimi.
Number Systems Spring Semester 2013Programming and Data Structure1.
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
Oct. 18, 2007SYSC 2001* - Fall SYSC2001-Ch9.ppt1 See Stallings Chapter 9 Computer Arithmetic.
Data Representation Dr. Ahmed El-Bialy Dr. Sahar Fawzy.
Number Systems and Codes. CS2100 Number Systems and Codes 2 NUMBER SYSTEMS & CODES Information Representations Number Systems Base Conversion Negative.
Computer Systems Architecture Copyright © Genetic Computer School 2008 CSA 1- 0 Lesson 1 Number System.
1 EENG 2710 Chapter 1 Number Systems and Codes. 2 Chapter 1 Homework 1.1c, 1.2c, 1.3c, 1.4e, 1.5e, 1.6c, 1.7e, 1.8a, 1.9a, 1.10b, 1.13a, 1.19.
CSC 221 Computer Organization and Assembly Language
ECE 456 Computer Architecture
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
1 Representation of Data within the Computer Oct., 1999(Revised 2001 Oct)
Today’s topics Architecture overview Architecture overview Machine instructions Machine instructions Instruction Execution Cycle Instruction Execution.
Computer Math CPS120 Introduction to Computer Science Lecture 4.
Computer Arithmetic See Stallings Chapter 9 Sep 10, 2009
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
CS1Q Computer Systems Lecture 2 Simon Gay. Lecture 2CS1Q Computer Systems - Simon Gay2 Binary Numbers We’ll look at some details of the representation.
Numbers in Computers.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
Chapter 1 Representing Data in a Computer. 1.1 Binary and Hexadecimal Numbers.
Computer Math CPS120 Introduction to Computer Science Lecture 7.
Number Systems. The position of each digit in a weighted number system is assigned a weight based on the base or radix of the system. The radix of decimal.
N 3-1 Data Types  Binary information is stored in memory or processor registers  Registers contain either data or control information l Data are numbers.
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
William Stallings Computer Organization and Architecture 8th Edition
Floating Point Representations
Programming and Data Structure
NUMBER SYSTEMS.
Number Representation
Data Representation Binary Numbers Binary Addition
CS1010 Programming Methodology
Data Representation Data Types Complements Fixed Point Representation
ECEG-3202 Computer Architecture and Organization
Presentation transcript:

Monday, January 14 Homework #1 is posted on the website Homework #1 is posted on the website Due before class, Jan. 16 Due before class, Jan. 16

Announcements Quiz #1 In class Wednesday, January 16 Covers Virtual machine (levels) Computer languages (levels) General architecture (CISC) VonNeumann architecture (stored program) Instruction Execution Cycle CPU, ALU, registers, buses, etc Internal/external representation Signed/unsigned integer IEEE floating-point Binary, decimal, hexadecimal Parity Characters (table provided) Integer arithmetic

Today’s topics More internal representation More internal representation Signed/unsigned integers Signed/unsigned integers External representation External representation Binary, decimal, hexadecimal number systems Binary, decimal, hexadecimal number systems Binary arithmetic Binary arithmetic Floating-point representation Floating-point representation Error-detecting and error-correcting codes Error-detecting and error-correcting codes

Other representations Every integer number has a unique representation in each "base"  2 Every integer number has a unique representation in each "base"  2 Hexadecimal is commonly used for easily converting binary to a more manageable form. Hexadecimal is commonly used for easily converting binary to a more manageable form. example 16-bit binary  hexadecimal: example 16-bit binary  hexadecimal: Binary Hexadecimal 1 7 B D Write it as 0x17BD or 17BDh

Converting decimal  hexadecimal Use same methods as decimal  binary Use same methods as decimal  binary The only difference is the place values The only difference is the place values Example decimal  hexadecimal Example decimal  hexadecimal 157 decimal = 9D hex(0x9D or 9Dh) … or convert to binary, then to hex … or convert to binary, then to hex

Negative hex (signed integers) How can you tell if a hexadecimal representation of a signed integer is negative? How can you tell if a hexadecimal representation of a signed integer is negative? Recall that a 16-bit signed integer is negative if the leftmost bit is 1 Recall that a 16-bit signed integer is negative if the leftmost bit is 1 16-bit (4 hex digits) examples: 16-bit (4 hex digits) examples: 0x7a3e is positive 0x7a3e is positive 0x8a3e is negative 0x8a3e is negative 0xFFFF is negative 0xFFFF is negative

Character and control codes Letters, digits, special characters … are represented internally as numbers Letters, digits, special characters … are represented internally as numbers ASCII256 codes (1-byte) ASCII256 codes (1-byte) e.g., 'A' … 'Z' are codes e.g., 'A' … 'Z' are codes e.g., '0' … '9' are codes e.g., '0' … '9' are codes Unicode65,536 codes (2-byte) Unicode65,536 codes (2-byte) Some codes are used for controlling devices Some codes are used for controlling devices e.g., code 10 is “new line” for output device e.g., code 10 is “new line” for output device e.g., code 27 is “escape” e.g., code 27 is “escape” Device controllers translate codes (device- dependent) Device controllers translate codes (device- dependent) All keyboard input is character (including digits) All keyboard input is character (including digits)

Digits Digits entered from the keyboard are characters Digits entered from the keyboard are characters E.G., ‘0’ is character number 48, … ‘9’ is character number 57 E.G., ‘0’ is character number 48, … ‘9’ is character number 57 What happens if we add ‘3’ + ‘5’? What happens if we add ‘3’ + ‘5’? The answer is ‘h’ The answer is ‘h’ Numeric data types require conversion by the input/output operations Numeric data types require conversion by the input/output operations

Neutral representation Inside the computer Inside the computer Bytes, words, etc., can represent some finite number of combinations of off/on switches. Bytes, words, etc., can represent some finite number of combinations of off/on switches. Each distinct combination is called a code. Each distinct combination is called a code. Each code can be used to represent: Each code can be used to represent: numeric value numeric value memory address memory address machine instruction machine instruction keyboard character keyboard character Representation is neutral. The operating system and the programs decide how to interpret the codes. Representation is neutral. The operating system and the programs decide how to interpret the codes.

Arithmetic operations The following examples use 8-bit twos- complement operands The following examples use 8-bit twos- complement operands Everything extends to 16-bit, 32-bit, n-bit representations. Everything extends to 16-bit, 32-bit, n-bit representations. What is the range of values for 8-bit operands? What is the range of values for 8-bit operands? The usual arithmetic operations can be performed directly in binary form with n-bit representations. The usual arithmetic operations can be performed directly in binary form with n-bit representations.

Addition Specify result size (bits) Specify result size (bits) Use the usual rules of add and carry Use the usual rules of add and carry With two operands, the carry bit is never greater than one With two operands, the carry bit is never greater than one = 1,0+1+1 = 10,1+0+1 = 10,1+1+1 = = 1,0+1+1 = 10,1+0+1 = 10,1+1+1 = 11 Example: Example: How does overflow occur? How does overflow occur?

Subtraction Use the usual rules Use the usual rules Order matters Order matters Borrow and subtract Borrow and subtract Example: Example: … or negate and add … or negate and add Example: Example: How does underflow occur? How does underflow occur?

Verification Perform operation on binary operands Perform operation on binary operands Convert result to decimal Convert result to decimal Convert operands to decimal Convert operands to decimal Perform operation on decimal operands Perform operation on decimal operands [Convert result to binary] [Convert result to binary] Compare results Compare results

Multiplication Usual algorithm Usual algorithm Repeated addition Repeated addition … or shift left (and adjust if multiplier is not a power of 2) … or shift left (and adjust if multiplier is not a power of 2) Check for overflow Check for overflow

Division Usual algorithm Usual algorithm Repeated subtraction Repeated subtraction … or shift right (if divisor is a power of 2) … or shift right (if divisor is a power of 2) too complicated if divisor is not a power of 2 too complicated if divisor is not a power of 2 Check underflow for remainder Check underflow for remainder

Arithmetic operations Note: all of the arithmetic operations can be accomplished using only Note: all of the arithmetic operations can be accomplished using only add add complement complement

Floating-point representation “decimal” means “base ten” “decimal” means “base ten” “floating-point” means “a number with an integral part and a fractional part “floating-point” means “a number with an integral part and a fractional part Sometimes call “real”, “float” Sometimes call “real”, “float” Generic term for “decimal point” is “radix point” Generic term for “decimal point” is “radix point”

Converting floating-point (decimal  binary) Place values: Place values: Integral partFractional part Example: 4.5 (decimal) = (binary)

Converting floating-point (decimal  binary) Example:6.25 = Example:6.25 = Method: Method: 6 = 110(Integral part: convert in the usual way).25 x 2 = 0.5(Fractional part: successive multiplication by 2).5 x 2 = 1.0(Stop when fractional part is 0) Example:6.2  … Example:6.2  … 6 = x 2 = x 2 = x 2 = x 2 = x 2 = 0.4(repeats)

Internal representation of floating- point numbers Some architectures handle the integer part and the fraction part separately Some architectures handle the integer part and the fraction part separately Slow Slow Most use a completely different representation and a different ALU (IEEE standard) Most use a completely different representation and a different ALU (IEEE standard) Range of values for 32-bit Range of values for 32-bit Approximately -3.4 x … +3.4 x Approximately -3.4 x … +3.4 x Limited precision Limited precision Approximately -1.4 x … +1.4 x Approximately -1.4 x … +1.4 x

IEEE 754 standard single-precision (32-bit) single-precision (32-bit) double-precision (64-bit) double-precision (64-bit) extended (80-bit) extended (80-bit) 3 parts 3 parts 1 sign bit 1 sign bit "biased" exponent (single: 8 bits, "biased" exponent (single: 8 bits, double: 11 bits double: 11 bits extended: 15 bits) extended: 15 bits) "normalized" mantissa (single: 23 bits, "normalized" mantissa (single: 23 bits, double: 52 bits double: 52 bits extended: 64 bits) extended: 64 bits)

Examples: 6.25 in IEEE single precision is 6.25 in IEEE single precision is C80000 hexadecimal 6.2 in IEEE is 6.2 in IEEE is C66666 hexadecimal SignBiased exponentNormalized mantissa

Examples: 6.25 in IEEE single precision 6.25 in IEEE single precision 6.25 (decimal) = (binary) Move the radix point until a single 1 appears on the left, and multiply by the corresponding power of 2 = x 2 2 = x 2 2 … so the sign bit is 0 (positive) … the “biased” exponent is = 129 = … and the “normalized” mantissa is 1001 (drop the 1, and zero-fill) C80000 hexadecimal

Examples: 6.2 in IEEE is 6.2 in IEEE is 6.2 (decimal) = … (binary) Move the radix point until a single 1 appears on the left, and multiply by the corresponding power of 2 = … x 2 2 = … x 2 2 … so the sign bit is 0 (positive) … the “biased” exponent is = 129= … … and the “normalized” mantissa is … (drop the 1) C66666 hexadecimal

What decimal floating-point number is represented by C H? What decimal floating-point number is represented by C H? … so the sign is negative … the “unbiased” exponent is = … and the “unnormalized” mantissa is (add the 1 left of the radix point). Move the radix point 4 places to the right: = = Example: SignBiased exponent Normalized mantissa

Internal representation Regardless of external representation, all I/O eventually is converted into electrical (binary) codes. Regardless of external representation, all I/O eventually is converted into electrical (binary) codes. Inside the computer, everything is represented by gates (open/closed). Inside the computer, everything is represented by gates (open/closed).

Problem with Internal Representation Since the number of gates in each group (byte, word, etc.) is finite, computers can represent numbers with finite precision only. Since the number of gates in each group (byte, word, etc.) is finite, computers can represent numbers with finite precision only. Examples: Examples: Suppose that signed integer data is represented using 16 bits. The largest integer that can be represented is What happens if we add 1 ? Suppose that signed integer data is represented using 16 bits. The largest integer that can be represented is What happens if we add 1 ? 0 0 What happens when we need to represent 1/3 ? What happens when we need to represent 1/3 ? Representations may be truncated; overflow / underflow can occur, and the Status Register will be set Representations may be truncated; overflow / underflow can occur, and the Status Register will be set Limited precision for floating-point representations Limited precision for floating-point representations

Looking inside … What does this code represent? What does this code represent? Number ? Number ? 8-bit unsigned 214 ? 8-bit unsigned 214 ? 8-bit signed - 42 ? 8-bit signed - 42 ? partial 16-bit integer ? partial 16-bit integer ? partial floating point ? partial floating point ? Character ? Character ? ASCII ‘ ╓ ’ ? ASCII ‘ ╓ ’ ? partial Unicode ‘Ö’ partial Unicode ‘Ö’ Address ? Address ? Instruction ? Instruction ? Garbage ? Garbage ?

Neutral representation Inside the computer Inside the computer Bytes, words, etc., can represent a finite number of combinations of off/on switches. Bytes, words, etc., can represent a finite number of combinations of off/on switches. Each distinct combination is called a code. Each distinct combination is called a code. Each code can be used to represent: Each code can be used to represent: numeric value numeric value memory address memory address machine instruction machine instruction keyboard character keyboard character Representation is neutral. The operating system and the programs decide how to interpret the codes. Representation is neutral. The operating system and the programs decide how to interpret the codes.

Simple Error Checking Each computer architecture is designed to use either even parity or odd parity Each computer architecture is designed to use either even parity or odd parity System adds a parity bit to make each code match the system's parity System adds a parity bit to make each code match the system's parity Parity is the total number of '1' bits (including the extra parity bit) in a binary code Parity is the total number of '1' bits (including the extra parity bit) in a binary code

Parity (error checking) Example parity bits for 8-bit code Example parity bits for 8-bit code Even-parity system: (sets parity bit to 1 to make a total of 6 one-bits) Even-parity system: (sets parity bit to 1 to make a total of 6 one-bits) Odd-parity system: (sets parity bit to 0 to keep 5 one-bits) Odd-parity system: (sets parity bit to 0 to keep 5 one-bits) Code is checked for parity error whenever it is used. Code is checked for parity error whenever it is used. Examples for even-parity architecture: Examples for even-parity architecture: error (5 one-bits) error (5 one-bits) OK (4 one-bits) OK (4 one-bits) Examples for odd-parity architecture: Examples for odd-parity architecture: OK (5 one-bits) OK (5 one-bits) error (4 one-bits) error (4 one-bits)

Parity (error checking) Used for checking memory, network transmissions, etc. Used for checking memory, network transmissions, etc. Error detection Error detection Not 100% reliable. Not 100% reliable. Works only when error is in odd number of bits Works only when error is in odd number of bits … but very good because most errors are single-bit … but very good because most errors are single-bit Next time … Next time … Error-correcting codes (ECC) Error-correcting codes (ECC)

Questions? Do Homework #1 Quiz #1 Wednesday