Information Representation. Reading and References Reading - Computer Organization and Design, Patterson and Hennessy Chapter 2, sec. 2.4, 2.9 (first.

Slides:



Advertisements
Similar presentations
ICS312 Set 2 Representation of Numbers and Characters.
Advertisements

Lecture - 2 Number systems and computer data formats
Floating Point Numbers
CS 61C L02 Number Representation (1)Harvey / Wawrzynek Fall 2003 © UCB 8/27/2003  Brian Harvey ( John Wawrzynek  (Warznek) (
Integer Types. Bits and bytes A bit is a single two-valued quantity: yes or no, true or false, on or off, high or low, good or bad One bit can distinguish.
Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates Invitation to Computer Science, C++ Version, Third Edition.
Data Representation Computer Organization &
COMP3221 lec06-numbers-II.1 Saeid Nooshabadi COMP 3221 Microprocessors and Embedded Systems Lecture 6: Number Systems - II
Data Representation COE 205
04/03/10CPE1002 (c) Monash University1 Number Systems and Data Representation Monash University School of Network Computing CPE 1002.
Chapter 3 Data Representation.

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 for Intel-Based Computers, 4th Edition
Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation.
1 Binary Arithmetic, Subtraction The rules for binary arithmetic are: = 0, carry = = 1, carry = = 1, carry = = 0, carry =
Number Representation (1) Fall 2005 Lecture 12: Number Representation Integers and Computer Arithmetic.
Data Representation ICS 233
1 Introduction Chapter 1 n What is Assembly Language? n Data Representation.
Number Systems Lecture 02.
Chapter 2 Bits, Data Types, and Operations. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 2-2 How do we.
Binary Representation and Computer Arithmetic
Chapter 5 Data representation.
CENG 311 Machine Representation/Numbers
Lecture 5.
Computers Organization & Assembly Language
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
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.
CSU0014 Assembly Languages Homepage: Textbook: Kip R. Irvine, Assembly Language for Intel-Based Computers,
2-1 Chapter 2 - Data Representation Principles of Computer Architecture by M. Murdocca and V. Heuring © 1999 M. Murdocca and V. Heuring Chapter Contents.
Computer Science 111 Fundamentals of Programming I Number Systems.
EX_01.1/46 Numeric Systems. EX_01.2/46 Overview Numeric systems – general, Binary numbers, Octal numbers, Hexadecimal system, Data units, ASCII code,
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Idea 1: Bits Two states in a digital machine: 1.presence of.
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
Number Systems Spring Semester 2013Programming and Data Structure1.
Digital Logic Design Lecture 3 Complements, Number Codes and Registers.
Lecture 4: Number Systems (Chapter 3) (1) Data TypesSection3-1 (2) ComplementsSection3-2 (3) Fixed Point RepresentationsSection3-3 (4) Floating Point RepresentationsSection3-4.
Computer Systems Organization CS 1428 Foundations of Computer Science.
ICS312 Set 1 Representation of Numbers and Characters.
Lecture Objectives: 1)Define the terms least significant bit and most significant bit. 2)Explain how unsigned integer numbers are represented in memory.
Introduction to Computer Engineering ECE/CS 252, Fall 2010 Prof. Mikko Lipasti Department of Electrical and Computer Engineering University of Wisconsin.
Information Representation. Digital Hardware Systems Digital Systems Digital vs. Analog Waveforms Analog: values vary over a broad range continuously.
9.4 FLOATING-POINT REPRESENTATION
Lecture 5. Topics Sec 1.4 Representing Information as Bit Patterns Representing Text Representing Text Representing Numeric Values Representing Numeric.
Bits, Data Types, and Operations Slides based on set prepared by Gregory T. Byrd, North Carolina State University.
Cosc 2150: Computer Organization Chapter 2 Part 1 Integers addition and subtraction.
BR 8/99 Binary Numbers Again Recall than N binary digits (N bits) can represent unsigned integers from 0 to 2 N bits = 0 to 15 8 bits = 0 to 255.
ECE 456 Computer Architecture
Chapter 19 Number Systems. Irvine, Kip R. Assembly Language for Intel-Based Computers, Translating Languages English: Display the sum of A times.
Chapter 2 Bits, Data Types, and Operations. 2-2 How do we represent data in a computer? At the lowest level, a computer is an electronic machine. works.
November 18, 2015Memory and Pointers in Assembly1 What does this C code do? int foo(char *s) { int L = 0; while (*s++) { ++L; } return L; }
EEL 3801C EEL 3801 Part I Computing Basics. EEL 3801C Data Representation Digital computers are binary in nature. They operate only on 0’s and 1’s. Everything.
Fixed & Floating Number Format Dr. Hugh Blanton ENTC 4337/5337.
Computer Architecture EKT 422
CDP ECE Spring 2000 ECE 291 Spring 2000 Lecture 2: Number Systems & x86 Instructions Constantine D. Polychronopoulos Professor, ECE Office: 463.
Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Signed Integers The highest bit indicates the sign. 1 = negative, 0 = positive.
Data Representation. Goal: Store numbers, characters, sets, database records in the computer. What we got: Circuit that stores 2 voltages, one for logic.
Number Systems and Computer Arithmetic Winter 2014 COMP 1380 Discrete Structures I Computing Science Thompson Rivers University.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
Data Representation COE 301 Computer Organization Dr. Muhamed Mudawar
Data Representation COE 301 Computer Organization Prof. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University of Petroleum.
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
Chapter 1 Introduction Digital Systems Digital systems: computation, data processing, control, communication, measurement - Reliable, Integration.
Lec 3: Data Representation
Data Representation Binary Numbers Binary Addition
Chapter 10 Instruction Sets: Characteristics and Functions
Presentation transcript:

Information Representation

Reading and References Reading - Computer Organization and Design, Patterson and Hennessy Chapter 2, sec. 2.4, 2.9 (first page only for now) 2

Review: A Computer is … main memory I/O bus processor/memory bus processor hardvideo /opticalserialnetwork diskcameradriveportsinterface 3

Processor & Memory For now we focus on the processor & memory Processor operation - Fetch next instruction from memory - Fetch instruction operands (data) from memory - Perform operation (add, subtract, test, …) - Store result (if any) in memory - Repeat Billions of times a second Memory holds all instructions and data What is memory made of? 4

Bits All memories are composed of (billions of) bits Abitis: - high or low voltage - 0or1 - true or false - yes or no - on or off It’s all how you interpret it But to store anything complicated we use a bunch of bits to make up a number, character, instruction, … 5

Computer Memory All memories are organized by grouping sets of bits into individual memory cells Each cell has an address and its contents Standard organization now: 1 cell = 8 bits = 1 byte A single byte can hold - A small integer (0-255 or ) - A single character (‘a’, ‘A’, ‘?’, ‘#’, ‘ ’, …) – A boolean value ( , ) 6

Memory Organization Memory is a linear array of bytes; each byte has an address (or location) - not the same as its contents Groups of bytes can be treated as a single unit 7

Some common storage units unit# bits byte8 half-word 16 word 32 double word 64 Terminology varies: this is how MIPS does it; the Intel x86 calls 16 bits a word & 32 bits a double-word 8

Alignment An object in memory is “aligned” when its address is a multiple of its size Byte: always aligned Halfword: address is multiple of 2 Word: address is multiple of 4 Double word: address is multiple of 8 Alignment simplifies load/store hardware - And is required by MIPS, but not x86 9

Binary Arithmetic Just as we do with decimal numbers, we can treat a collection of bits as a multi-digit number in base 2 Example: = 1 × × × × 2 0 = ____________ You try it: = ____________ ? 10

Binary, Hex, and Decimal It’s unwieldy to work with long strings of binary digits, so we group them in chunks of 4 and treat each chunk as a digit in base 16 Hex digits: -0 = 0000,1 = 0001,2 = 0010,3 = 0011 – 4 = 0100,5 = 0101,6 = 0110,7 = 0111 – 8 = 1000,9 = 1001, __ = 1010, __ = 1011 – _ = 1100, __ = 1101, __ = 1110, __ = 1111 Usual notation for hex integer in C, Java, …: 0x1c4 11

Hex Numbers What is 0x2a5 in decimal? - 0x2a5 = 2 × a × × 16 0 = ________________________________ What about 0xbad? _____________________ Be sure you realize that 0x11 ≠ ≠

More problems What is in hex? ______________________________________ What is 0xbeef in binary? - (Hint: there’s a trick) _______________________________________ 13

Binary, Hex, and Decimal Binary 2 Hex x x xA xF x x1F x7F xFF

Binary, Hex, and Decimal Hex 16 Decimal x x xA xF x x1F x7F xFF255 15

Binary, Hex, and Decimal Binary 2 Decimal A F F F F

Unsigned binary numbers Each bit represents a power of 2 For unsigned numbers in a fixed width n-bit field: - 2 n distinct values - the minimum value is 0 - the maximum value is 2 n-1, where n is the number of bits in the field Fixed field widths determine many limits - 5bits=32possiblevalues(2 5 = 32) - 10 bits = 1024 possible values (2 10 = 1024) 17

Signed Numbers For unsigned numbers, - each bit position represents a power of 2 - range of values is 0 to 2 n -1 How can we indicate negative values? - two states: positive or negative - a binary bit indicates one of two states: 0 or 1 ⇒ use one bit for the sign bit 18

Where is the sign bit? Could use an additional bit to indicate sign - each value would require 33 bits - would really foul up the hardware design Could use any bit in the 32-bit word - any bit but the left-most (high order) would complicate the hardware tremendously ∴ The high order bit (left-most) is the sign bit - remaining bits indicate the value 19

Format of 32-bit signed integer sign bitnumeric value (1 bit)(31 bits) Bit 31 is the sign bit - 0 for positive numbers, 1 for negative numbers - aka most significant bit (msb), high order bit 20

Example: 4-bit signed numbers Hex Bin F 1111 E 1110 D 1101 C 1100 B 1011 A Unsigned Signed Decimal sign bit (1 bit) numeric value (3 bits)

Two’s complement notation Note special arrangement of negative values One zero value, one extra negative value The representation is exactly what you get by doing a subtraction DecimalBinary

Why “two’s” complement? In an n-bit binary word, negative x is represented by the value of 2 n -x. The radix (or base) is 2. 4-bit example 2 4 = 16. What is the representation of -6? DecimalBinary

Negating a number Given x, how do we represent negative x? negative(x) = 2 n -x and x+complement(x) = 2 n -1 sonegative(x) = 2 n -x = complement(x)+1 The easy shortcut - write down the value in binary - complement all the bits - add 1 24

Example: the negation shortcut decimal 6 = 0110 = +6 complement = 1001 add 1 = 1010 = -6 decimal -6 = 1010 = -6 complement = 0101 add 1 = 0110 = +6 25

Why 2’s complement? (Again) The key advantage is that we can add two numbers together without paying any attention to the sign and we get the properly signed result 26

What About Non-Numeric Data? Everything is bits So assign (arbitrarily) specific bit patterns (numbers) to represent different characters Two most common codes - ASCII - original 7-bit code, early 1960’s How many possible characters? - Unicode to 32-bit code to represent enough different characters to encode all currently used alphabets; started in the late 1980s 27

ASCII 33!49165A81Q97a113q 34 ” 50266B82R98b114r 35#51367C83S99c115s 36$52468D84T100d116t 37%53569E85U101e117u 38&54670F86V102f118v 39 ’ 55771G87W103g119w 40(56872H88X104h120x 41)57973I89Y105I121y 42*58:74J90Z106j122z 43+59;75K91[107k123{ 44,60<76L92\108l124| 45-61=77M93]109m125} 4662>78N94^110n126~ 47/63?79O95111o127del 28

But wait, there’s more! We still haven’t looked at - Floating-point numbers (scientific notation) - Strings/arrays - Records/structs/objects - Colors and images - Sounds We’ll see some of this, but it’s all encoded as numbers (i.e., collections of bits) But next we need to look at how the computer processes these things - instructions 29