University of Gujrat Department of Computer Science

Slides:



Advertisements
Similar presentations
Assembly Language for Intel-Based Computers, 4 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify and.
Advertisements

DATA REPRESENTATION CONVERSION.
Assembly Language and Computer Architecture Using C++ and Java
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify.
Mantıksal Tasarım – BBM231 M. Önder Efe
Data Representation in Computers. Data Representation in Computers/Session 3 / 2 of 33 Number systems  The additive approach – Number earlier consisted.
Dr. Bernard Chen Ph.D. University of Central Arkansas
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify.
(2.1) Fundamentals  Terms for magnitudes – logarithms and logarithmic graphs  Digital representations – Binary numbers – Text – Analog information 
ACOE1611 Data Representation and Numbering Systems Dr. Costas Kyriacou and Dr. Konstantinos Tatas.
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.
EKT 121 / 4 ELEKTRONIK DIGIT 1 CHAPTER 1 : INTRODUCTION.
CSU0014 Assembly Languages Homepage: Textbook: Kip R. Irvine, Assembly Language for Intel-Based Computers,
Binary Numbers.
Summer 2014 Chapter 1: Basic Concepts. Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Chapter Overview Welcome to Assembly Language.
©zaher elsir Sudan Academy for Banking & Financial Sciences Decimal Number System Base (Radix)10 Digits0, 1, 2, 3, 4, 5, 6, 7, 8, 9 e.g The magnitude.
Assembly Language for x86 Processors 7th Edition
Click to edit Master title style Click to edit Master text styles –Second level Third level –Fourth level »Fifth level 1 Today’s Topics How information.
Logic and Digital System Design - CS 303
CS Binary Representation of Information Detecting Voltage Levels Why not 10 levels? Would be unreliable Not enough difference between states On/Off.
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION.
Logic Design Dr. Yosry A. Azzam. Binary systems Chapter 1.
مدار منطقي مظفر بگ محمدي Course Structure & Grading Homework: 25% Midterm: 30% Final:50% There is 5% extra! ( =105!) Textbook:
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
Engineering 1040: Mechanisms & Electric Circuits Spring 2014 Number Systems.
1 DLD Lecture 18 Recap. 2 Recap °Number System/Inter-conversion, Complements °Boolean Algebra °More Logic Functions: NAND, NOR, XOR °Minimization with.
CPU Internal memory I/O interface circuit System bus
Course contents Chapter 1 - section 1.6 Chapter 2 - all sections Chapter – 4.7, and 4.12 Chapter , Chapter 6 - all sections.
Number systems, Operations, and Codes
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.
Data Representation, Number Systems and Base Conversions
AEEE2031 Data Representation and Numbering Systems.
June 10, 2002© Howard Huang1 Number systems To get started, we’ll discuss one of the fundamental concepts underlying digital computer design:
WEEK #2 NUMBER SYSTEMS, OPERATION & CODES (PART 1)
Logic Design EE-2121 Manesh T. Digital Systems  Introduction  Binary Quantities and Variables  Logic Gates  Boolean Algebra  Combinational Logic.
CSC 331: DIGITAL LOGIC DESIGN COURSE LECTURER: E. Y. BAAGYERE. CONTACT: LECTURE TIME: 15:40 – 17:45 hrs. VENUE: SP-LAB.
BINARY SYSTEMS ENGR. KASHIF SHAHZAD 1. BINARY NUMBERS 1/2 Internally, information in digital systems is of binary form groups of bits (i.e. binary numbers)
CHAPTER 3 BINARY NUMBER SYSTEM. Computers are electronic machines which operate using binary logic. These devices use two different values to represent.
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.
Unit 1 Introduction Number Systems and Conversion.
NUMBER SYSTEMS.
Computer Code.
Digital Logic and Computer Organization
3.1 Denary, Binary and Hexadecimal Number Systems
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
CHAPTER 1 : INTRODUCTION
Introduction The term digital is derived from the way computers perform operation, by counting digits. Application of digital technology: television, communication.
Chapter 3 Data Representation
Number System conversions
Number Systems.
Fundamentals & Ethics of Information Systems IS 201
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
Digital Electronics & Logic Design
ELL100: INTRODUCTION TO ELECTRICAL ENGG.
Data Representation in Computer Systems
Numbering System TODAY AND TOMORROW 11th Edition
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
Digital Logic Design (ECEg3141) 2. Number systems, operations & codes 1.
CPS120: Introduction to Computer Science
Digital Systems and Binary Numbers
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
2’s Complement form 1’s complement form 2’s complement form
Number Systems Rayat Shikshan Sanstha’s
Chapter Four Data Representation in Computers By Bezawit E.
Number Systems Rayat Shikshan Sanstha’s
COMS 161 Introduction to Computing
UNIT – 3 & 4. Data Representation and Internal
CSE 370 – Winter Number syst.; Logic functions- 1
Presentation transcript:

University of Gujrat Department of Computer Science Course Code : CS-252 Computer Organization and Assembly Language Lecture # 3 Data Representation and Conversion Boolean Operations University of Gujrat

Data Representation & Conversion University of Gujrat

Data Representation How do computers represent data? Most computers are digital Recognize only two discrete states: on or off Computers are electronic devices powered by electricity, which has only two states, on or off on 1 1 1 1 1 0 0 0 0 0 off University of Gujrat

Different ways to say how many Number Systems Different ways to say how many University of Gujrat

Number Systems Decimal (0-9) Base 10 Binary (0,1) Base 2 Octal (0-7) Base 8 Hexadecimal (0-F) {0-9, A, B, C, D, E, F} Base 16 University of Gujrat

There are 10 symbols that represent quantities: Decimal Number System The prefix “deci-” stands for 10 The decimal number system is a Base 10 number system: – There are 10 symbols that represent quantities: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Positional Number system - each digit is associated with the power of 10 For e.g. 3,932 = 3 x 103 + 9 x 102 + 3 x 101 + 2 x 100 University of Gujrat

Binary Number System A number system that has just two unique digits, 0 and 1 A single digit is called a bit (binary digit) A bit is the smallest unit of data the computer can represent By itself a bit is not very informative The two digits represent the two off and on states Binary Digit (bit) Electronic Charge Electronic State University of Gujrat

The Octal and Hexadecimal Numbering Systems Computers use the binary system to represent data. In most cases a number is represented with 16, 32 or more bits, which is difficult to be handled by humans. To make binary numbers easier to manipulate, we can group the bits of the number in groups of 2, 3 or 4 bits. If we take a group of 2 bits, then we can have 4 combinations or different digits in each group. Thus the new system is a system with the base of 4. e.g. (10110100)2= (10 11 01 00)2= (2310)4 (11)2 = 3 (00)2 = 0 (10)2 = 2 (01)2 = 1 University of Gujrat

The Octal and Hexadecimal Numbering Systems (Cont.) If we take a group of 3 bits, then we can have 8 combinations or different digits in each group. Thus the new system is a system with the base of 8 and is called the Octal system. e.g. (10110100)2= (10 110 100)2= (264)8 If we take a group of 4 bits, then we can have 16 combinations or different digits in each group. Thus the new system is a system with the base of 16 and is called the hexadecimal or hex system. Letters A to F are used to represent digits from 10 to 15. e.g. (10110100)2= (1011 0100)2= (B4)16 (110)2 = 6 (010)2 = 2 (100)2 = 4 (1011)2 =11=B (0100)2 = 4 University of Gujrat

Decimal, Binary, Octal and Hexadecimal Conversion Table Decimal Binary Base 4 Octal Hex 0 0000 0 0 0 1 0001 1 1 1 2 0010 2 2 2 3 0011 3 3 3 4 0100 10 4 4 5 0101 11 5 5 6 0110 12 6 6 7 0111 13 7 7 8 1000 20 10 8 9 1001 21 11 9 10 1010 22 12 A 11 1011 23 13 B 12 1100 30 14 C 13 1101 31 15 D 14 1110 32 16 E 15 1111 33 17 F University of Gujrat

Conversion from Decimal to a system with base R A decimal number can be converted into its equivalent in base R using the following procedure: e.g Decimal Number = 88 R = 2 Step 1: Perform the integer division of the decimal number (88) by R (2) and record the remainder. Replace the decimal number with the result of the division. Step 2: Repeat step 1, until a zero result is found. e.g. 2 88 2 44 - 0 2 22 - 0 2 11 - 0 2 5 - 1 2 2 - 1 1 - 0 Step 3: The number is formed by reading the remainders in reversed order. e.g. (88)10 = (1011000)2

Binary Arithmetic University of Gujrat

Binary Addition Starting with the LSB, add each pair of digits, include the carry if present. Addition Rules 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 0 (1 carry to next bit) Practice: Add 00111101 and 00111100. University of Gujrat University of Gujrat 13

Signed-Magnitude Used 1st bit of the number as a sign indicator e.g. +5  0101 -5  1101 -4  1100 Easy to understand but not efficient Two representations for zero Complexity of arithmetic and complex hardware (adder, subtractor, comparator) required ALU performs addition mainly We would need to redesign the ALU to do arithmetic with signed-magnitude representation What’s the alternative? University of Gujrat

2’s complement The high-order bit represents the sign but the magnitude is computed differently Has a single representation for zero No extra overhead for binary arithmetic Almost all modern computers use this representation An n-bit binary number can represent -2n-1 – 2n-1-1 (if n=4, -8 – +7 can be represented) University of Gujrat

Converting Decimal to 2’s Complement Get the binary representation for the absolute value of the number Flip all the bits Add 1 to the complement Example -3 00011 // 5-bit binary for absolute value of -3 11100 // all bits flipped 11101 // 1 added to the complement Practice: Convert -6 in 2’s complement University of Gujrat

Converting 2’s Complement to Decimal If the high-order bit is 0 then convert the number in the usual way Else Subtract 1 Flip all bits Convert to decimal Affix a minus sign Example 11010 // 2’s complement binary 11001 // 1 subtracted 00110 // bits flipped -6 // affixed the negative sign .Practice: Convert 11010 to Decimal. University of Gujrat

2’s Complement Arithmetic Binary addition, discard the final carry Example Be careful of overflow For a 5 bit 2’s complement representation 16 is too large! -17 is too small! Example: -3 1101 + -6 + 1010 ---- -------- -9 10111 University of Gujrat

Binary Subtraction When subtracting A – B, convert B to its two's complement Add A to (–B) 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 – 0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 1 0 0 0 0 1 0 0 1 Practice: 7+ (-4). University of Gujrat

Hexadecimal Arithmetic University of Gujrat

Hexadecimal Addition 36 28 28 6A 42 45 58 4B 78 6D 80 B5 Divide the sum of two digits by the number base (16). The quotient becomes the carry value, and the remainder is the sum digit. 1 1 36 28 28 6A 42 45 58 4B 78 6D 80 B5 21 / 16 = 1, rem 5 Practice: Add 34F4 and 2A12. University of Gujrat

Hexadecimal Subtraction When a borrow is required from the digit to the left, add 16 (decimal) to the current digit's value: 16 + 5 = 21 -1 C6 75 A2 47 24 2E Practice: Subtract 2A12 from 34F4. University of Gujrat

Character Storage Character Set Standard ASCII (0 – 127) Extended ASCII (0 – 255) Unicode (0 – 65,535) University of Gujrat

University of Gujrat

Boolean Operations University of Gujrat

Boolean Operations NOT AND OR Operator Precedence Truth Tables University of Gujrat

Boolean Algebra Based on symbolic logic, designed by George Boole Boolean expressions created from: NOT, AND, OR University of Gujrat

Digital gate diagram for NOT: Inverts (reverses) a boolean value Truth table for Boolean NOT operator: Digital gate diagram for NOT: University of Gujrat

Digital gate diagram for AND: Truth table for Boolean AND operator: Digital gate diagram for AND: University of Gujrat

Digital gate diagram for OR: Truth table for Boolean OR operator: Digital gate diagram for OR: University of Gujrat

NAND &&& NOr NANd is reverse of AND NOR is reverse of OR University of Gujrat

XOR IF both inputs are false or both inputs are ture false output is returned by XOR. University of Gujrat

XOR A B A XOR B F T University of Gujrat

Operator Precedence Examples showing the order of operations: University of Gujrat

Truth Tables (1 of 3) Example: X  Y A Boolean function has one or more Boolean inputs, and returns a single Boolean output. A truth table shows all the inputs and outputs of a Boolean function Example: X  Y University of Gujrat

Truth Tables (2 of 3) Example: X  Y University of Gujrat

Truth Tables (3 of 3) Example: (Y  S)  (X  S) Practice: (Y v S )  (X v S). University of Gujrat

THE END University of Gujrat