Assembly Language for Intel-Based Computers

Slides:



Advertisements
Similar presentations
Number Systems and Codes
Advertisements

Assembly Language for Intel-Based Computers, 4 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify and.
Data Representation COE 202 Digital Logic Design Dr. Aiman El-Maleh
ICS312 Set 2 Representation of Numbers and Characters.
HEXADECIMAL NUMBERS Code
The Binary Numbering Systems
Lecture - 2 Number systems and computer data formats
TK 2123 COMPUTER ORGANISATION & ARCHITECTURE Lecture 4: Data in The Computer Dr. Masri Ayob.
Data Representation Computer Organization &
Data Representation COE 205
Chapter 3 Data Representation.
Assembly Language and Computer Architecture Using C++ and Java
Assembly Language for Intel-Based Computers, 4th Edition
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify.
Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation.
CSCE 211: Digital Logic Design Chin-Tser Huang University of South Carolina.
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify.
Data Representation ICS 233
VIT UNIVERSITY1 ECE 103 DIGITAL LOGIC DESIGN CHAPTER I NUMBER SYSTEMS AND CODES Reference: M. Morris Mano & Michael D. Ciletti, "Digital Design", Fourth.
Codes and number systems Introduction to Computer Yung-Yu Chuang with slides by Nisan & Schocken ( ) and Harris & Harris (DDCA)
Connecting with Computer Science 2 Objectives Learn why numbering systems are important to understand Refresh your knowledge of powers of numbers Learn.
Assembly Language for Intel-Based Computers, 5 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify.
Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify and copy this slide show for your personal use, or for.
Simple Data Type Representation and conversion of numbers
Computers Organization & Assembly Language
CSU0014 Assembly Languages Homepage: Textbook: Kip R. Irvine, Assembly Language for Intel-Based Computers,
Summer 2014 Chapter 1: Basic Concepts. Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Chapter Overview Welcome to Assembly Language.
Assembly Language for x86 Processors 7th Edition
#1 Lec # 2 Winter EECC341 - Shaaban Positional Number Systems A number system consists of an order set of symbols (digits) with relations.
CPS120: Introduction to Computer Science Midterm Exam Review.
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
ECEN2102 Digital Logic Design Lecture 1 Numbers Systems Abdullah Said Alkalbani University of Buraimi.
ICS312 Set 1 Representation of Numbers and Characters.
Assembly Language for x86 Processors 7 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify and copy this.
Information Representation. Digital Hardware Systems Digital Systems Digital vs. Analog Waveforms Analog: values vary over a broad range continuously.
Logic Design Dr. Yosry A. Azzam. Binary systems Chapter 1.
©Brooks/Cole, 2003 Chapter 3 Number Representation.
CPU Internal memory I/O interface circuit System bus
ECE 301 – Digital Electronics Unsigned and Signed Numbers, Binary Arithmetic of Signed Numbers, and Binary Codes (Lecture #2)
Chapter 19 Number Systems. Irvine, Kip R. Assembly Language for Intel-Based Computers, Translating Languages English: Display the sum of A times.
EET 250 Number systems. Introduction to Number Systems While we live in a world where the decimal number is predominant in our lives, computers and digital.
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
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.
Computer Organization and Assembly Languages 2007/11/10
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
CPS120: Introduction to Computer Science Midterm Exam Review.
MECH1500 Chapter 3.
Data Representation.
CPEN Digital Logic Design Binary Systems Spring 2004 C. Gerousis © Digital Design 3 rd Ed., Mano Prentice Hall.
© Prepared By: Razif Razali 1 CHAPTER TWO TCS1023 NUMBERING SYSTEM.
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.
Chapter 1 Digital Systems and Binary Numbers
Data Representation COE 308 Computer Architecture
4th Edition, Irv Englander
Data Representation ICS 233
Lec 3: Data Representation
Data Representation.
Assembly Language (CSW 353)
Data Representation Binary Numbers Binary Addition
CHAPTER 1 : INTRODUCTION
University of Gujrat Department of Computer Science
Data Representation COE 301 Computer Organization
Number Systems Lecture 2.
Computer Organization and Assembly Language
Data Representation ICS 233
Data Representation COE 308 Computer Architecture
Presentation transcript:

Assembly Language for Intel-Based Computers DATA REPRESENTATION Part 1

Data Formats Computers Human communication Data formats: Process and store all forms of data in binary format Human communication Includes language, images and sounds Data formats: Specifications for converting data into computer-usable form Define the different ways human data may be represented, stored and processed by a computer

Sources of Data Binary input Analog Begins as discrete input Example: keyboard input such as A 1+2=3 math Keyboard generates a binary number code for each key Analog Continuous data such as sound or images Requires hardware to convert data into binary numbers Figure 3.1 with this color scheme Computer 1101000101010101… Input device A 1+2=3 math

Common Data Representations Type of Data Standard(s) Alphanumeric Unicode, ASCII, EDCDIC Image (bitmapped) GIF (graphical image format) TIF (tagged image file format) PNG (portable network graphics) Image (object) PostScript, JPEG, SWF (Macromedia Flash), SVG Outline graphics and fonts PostScript, TrueType Sound WAV, AVI, MP3, MIDI, WMA Page description PDF (Adobe Portable Document Format), HTML, XML Video Quicktime, MPEG-2, RealVideo, WMV

Internal Computer Data Format All data stored as binary numbers Interpreted based on Operations computer can perform Data types supported by programming language used to create application

Internal Data Representation Reflects the Complexity of input source Type of processing required Trade-offs Accuracy and resolution Simple photo vs. painting in an art book Compactness (storage and transmission) More data required for improved accuracy and resolution Compression represents data in a more compact form Metadata: data that describes or interprets the meaning of data Ease of manipulation: Processing simple audio vs. high-fidelity sound Standardization Proprietary formats for storing and processing data (WordPerfect vs. Word) De facto standards: proprietary standards based on general user acceptance (PostScript)

5 Simple Data Types Boolean: 2-valued variables or constants with values of true or false Char: Variable or constant that holds alphanumeric character Enumerated User-defined data types with possible values listed in definition Type DayOfWeek = Mon, Tues, Wed, Thurs, Fri, Sat, Sun Integer: positive or negative whole numbers Real Numbers with a decimal point Numbers whose magnitude, large or small, exceeds computer’s capability to store as an integer

Data Types: Numeric Used for mathematical manipulation Add, subtract, multiply, divide Types Integer (whole number) Real (contains a decimal point) pure binary can be calculated directly ASCII binary string of digits: "01010101" ASCII decimal string of digits: "65" ASCII hexadecimal string of digits: "9C"

Data Types: Alphanumeric Characters: b T Number digits: 7 9 Punctuation marks: ! ; Special-purpose characters: $ & Numeric characters vs. numbers Both entered as ordinary characters Computer converts into numbers for calculation Examples: Variables declared as numbers by the programmer (Salary$ in BASIC) Treated as characters if processed as text Examples: Phone numbers, ZIP codes

Alphanumeric Codes Arbitrary choice of bits to represent characters Consistency: input and output device must recognize same code Value of binary number representing character corresponds to placement in the alphabet Facilitates sorting and searching

Data Representation Binary Numbers Translating between binary and decimal Binary Addition Integer Storage Sizes Hexadecimal Integers Translating between decimal and hexadecimal Hexadecimal subtraction Signed Integers Binary subtraction Character Storage

Binary, Octal, Decimal and Hexadecimal Digits Table System Base Possible Digits Binary 2 0 1 Octal 8 0 1 2 3 4 5 6 7 Decimal 10 0 1 2 3 4 5 6 7 8 9 Hexadecimal 16 0 1 2 3 4 5 6 7 8 9 A B C D E F

Binary Numbers Digits are 1 and 0 1 = true 0 = false MSB – most significant bit LSB – least significant bit Bit numbering:

Binary Numbers Binary integers can be signed or unsigned. Signed integer = either positive or negative Unsigned integer = only positive, including 0.

Unsigned Binary Integers Each digit (bit) is either 1 or 0 Each bit represents a power of 2 Every binary number is a sum of powers of 2

Translating Unsigned Binary to Decimal Weighted positional notation shows how to calculate the decimal value of each binary bit: dec = (Dn-1  2n-1) + (Dn-2  2n-2) + ... + (D1  21) + (D0  20) D = binary digit binary 00001001 = decimal 9: How to calculate? ( 0 27)+(0  26)+(0  25)+(0  24)+(1  23)+(0  22)+ (0  21)+ (1  20) 0 + 0 + 0 + 0 + 8 + 0 + 0 + 1  9

Translating Binary to Decimal Try this 010011002 100000012 101010102 110011002

Translating Unsigned Decimal to Binary Repeatedly divide the decimal integer by 2. Each remainder is a binary digit in the translated value: 37 = 1001012

Translating Decimal to Binary Try this 55 16 77 111

Binary Addition Starting with the LSB, add each pair of digits, include the carry if present.

Integer Storage Sizes Standard sizes: What is the largest unsigned integer that may be stored in 20 bits?

Hexadecimal Integers Binary values are represented in hexadecimal.

Translating Binary to Hexadecimal Each hexadecimal digit corresponds to 4 binary bits. Example: Translate the binary integer 000101101010011110010100 to hexadecimal:

Powers of 16 From 160 to 167 Used when calculating hexadecimal values up to 8 digits long:

Converting Hexadecimal to Decimal Multiply each digit by its corresponding power of 16: decimal = (D3  163) + (D2  162) + (D1  161) + (D0  160) Hex 1234 equals (1  163) + (2  162) + (3  161) + (4  160), or decimal 4,660. Hex 3BA4 equals (3  163) + (11 * 162) + (10  161) + (4  160), or decimal 15,268.

Converting Hexadecimal to Decimal (cont) Try this: 1C59 ABCD Hex 3BA4 equals 3 * 163 = 12 288 + 11 * 162 = 2 816 + 10 * 161 = 160 + 4 * 160 = 4 15,268

Converting Decimal to Hexadecimal Try this: 100 2108 decimal 422 = 1A6 hexadecimal

Hexadecimal Addition eg: 1 6 A  6 | 10 + 4 B  4 | 11 11 | 21 B 5 Divide the sum of two digits by the number base (16). The quotient becomes the carry value, and the remainder is the sum digit. eg: 1 6 A  6 | 10 + 4 B  4 | 11 11 | 21 B 5 Try This 36 28 28 +42 + 45 + B8 21/16 = 1, remain 5 1/16 = 0, remain 1 Important skill: Programmers frequently add and subtract the addresses of variables and instructions.

Solution A2 : A3 : 2 | 8 2 | 8 + 4 | 5 + B | 8 6 | 13 6 D 14 | 16 E 0 16 /16 = 1 remain 0 1/16 = 0 remain 1 14 = E

Hexadecimal Subtraction When a borrow is required from the digit to the left, add 16 (decimal) to the current digit's value: 16 2 8 16 3 9 5 3 9 5 - D A - 13 10 2 11 11 2 B B C 6 12 6 - A 2 -10 2 2 4 (16+5)-10 =11 (16+8)-13 =11

Hexadecimal Subtraction 6 16 7 5 4 7 2 E 16 + 5 = 21 21 – 7 = 14 14 = E F = 15 15 – 2 = 13 13 = D E =14 B = 11 14 – 11 = 3 E F B 2 3 D

Try this Hexadecimal addition Hexadecimal subtraction D3A + 19 6B2 + FF Hexadecimal subtraction D1A - 339 A11 - 99 74B – 8F

Signed Integers The highest bit indicates the sign. 1 = negative, 0 = positive If the highest digit of a hexadecimal integer is > 7, the value is negative. Examples: 8A, C5, A2, 9D

Signed-Integer Representation No obvious direct way to represent the sign in binary notation Options: Sign-and-magnitude representation 1’s complement 2’s complement (most common)

Sign-and-Magnitude Use left-most bit for sign 0 = plus; 1 = minus Total range of integers the same Half of integers positive; half negative Magnitude of largest integer half as large Example using 8 bits: Unsigned: 1111 1111 = +255 Signed: 0111 1111 = +127 1111 1111 = -127 Note: 2 values for 0: +0 (0000 0000) and -0 (1000 0000)

1’s vs. 2’s Complements Choice made by computer designer Reverse the bit Easier to change sign Addition requires extra end-around carry Algorithm must test for and convert -0 2’s complement simpler Additional add operation required for sign change

Forming the Two's Complement Negative numbers are stored in two's complement notation Represents the additive Inverse Note that 00000001 + 11111111 = 00000000

Forming Two’s Complement of Hexadecimal Step 1: reverse the bits = 95C2 Step 2: Add 1 = 95C3

Learn How To Do the Following: Form the two's complement of a hexadecimal integer Convert signed binary to decimal Convert signed decimal to binary Convert signed decimal to hexadecimal Convert signed hexadecimal to decimal

Guidelines Convert signed binary to decimal If number is negative, form two complement notation Convert to decimal Convert signed decimal to binary Convert to binary Convert signed decimal to hexadecimal Convert to hexadecimal Convert signed hexadecimal to decimal

**notes** Any hexadecimal number If digit is >= 8, the number is negative If digit is <=7, the number is positive Eg : 8A20 = negative 7FD9 = positive

Ranges of Signed Integers The highest bit is reserved for the sign. This limits the range: Practice: What is the largest positive value that may be stored in 20 bits?

Numeric Data Representation pure binary can be calculated directly ASCII binary string of digits: "01010101" ASCII decimal string of digits: "65" ASCII hexadecimal string of digits: "9C" next: Boolean Operations

Learn How To Do the Following: Form the two's complement of a hexadecimal integer 3D C2 (First complement) + 1 C3 (Two’s Complement) Convert signed binary to decimal 1111 0000 0000 1111 (First complement) + 1 0001 0000 (Two’s Complement) 0001 0000 =( 1 X 2 ^ 5) =16 =16

Learn How To Do the Following: Convert signed decimal to binary - 43 =? 43= 00101011 Two’s Complement: 0010 1011 1101 0100 + 1 1101 0101 Convert signed decimal to hexadecimal -18 =? * Twist 18=12 hexadecimal Two’s complement: 15 15 - 1 2 E D + 1 E E

Learn How To Do the Following: Convert signed hexadecimal to decimal - 8C =? 8= -ve integer hexadecimal Two complements: 15 15 - 8 C 7 3 + 1 7 4 =(7 X 16 1) + (4 X 16 0) =112+4=116 8C = -116