Download presentation
Presentation is loading. Please wait.
Published byAriel Parrish Modified over 9 years ago
1
CIS 020 Assembly Programming Chapter 02 - Numbering Systems & Data Representation © John Urrutia 2012, All Rights Reserved.5/27/20121
2
Numbering Systems What are number systems? A system of numeration for expressing numbers, that is a mathematical notation for representing numbers of a given set. We learned the decimal numbering system in grammar school and we need to review that now. © John Urrutia 2012, All Rights Reserved.25/27/2012
3
Numbering Systems Each digit of a decimal number can have only 1 of 10 values three digit number Each digit’s position in the number from right to left is an order of magnitude greater © John Urrutia 2012, All Rights Reserved.35/27/2012 109 100’s10’s1’s
4
Numbering Systems Given a 4 digit decimal number we see the relationship of the digits as follows: We have 1 thousand, no hundreds, 9 tens & 5 ones in this number © John Urrutia 2012, All Rights Reserved.45/27/2012 10 3 10 2 10 1 10 0 1095
5
Numbering Systems Number System Basics The “Base” of a number system is the maximum value represented by a single digit. Each digit’s position, from right to left, is an exponent of the “Base” raised to the power of the position, starting at zero Each digit’s value is the multiplier of the position’s exponent Base 10 numbers are not directly compatible with Base 2 numbers. © John Urrutia 2012, All Rights Reserved.55/27/2012
6
Numbering Systems Decimal numbers are not compatible with digital computers ? The bases are not multiple of each other and require conversion routines. What are binary, octal, decimal and hexadecimal? Binary Numbers, 2 values for each digit – 0 and 1 Octal Numbers, 8 values for each digit – 0 thru 7 Decimal Numbers, 10 values for each digit – 0 thru 9 Hexadecimal Numbers, 16 values for each digit 0 thru 9 and A thru F © John Urrutia 2012, All Rights Reserved.65/27/2012
7
Numbering Systems Digital computers use binary – Base 2 Each digit of the binary number is call a BIT The decimal equivalent is © John Urrutia 2012, All Rights Reserved.75/27/2012 23232 2121 2020 1010 10 3 10 2 10 1 10 0 0010
8
Numbering Systems Since we deal in decimal numbers & computers deal in binary numbers, we need to learn to convert from one to the other. The Remainder Method to Convert from decimal Divide by the base – Quotient is the high order digit Remainder used for subsequent digits – Repeat until Remainder is less than base Last Remainder is low order digit © John Urrutia 2012, All Rights Reserved.85/27/2012
9
Numbering Systems The Multiplier method to Convert to decimal For each digit in the number to convert: Calculate the exponentiated positional value Multiply it by the digit’s value. Add the result to the decimal total © John Urrutia 2012, All Rights Reserved.95/27/2012
10
Numbering Systems Basic Arithmetic Adding If the sum of two digits is greater than the base carry over to the next position in the number Subtracting If the difference of two digits is less than zero barrow a digit from the next position in the number © John Urrutia 2012, All Rights Reserved.105/27/2012
11
Data Representation The problem: How do I represent standard printable characters using binary values? The answer: Develop a code where every printable character has a unique binary value! © John Urrutia 2012, All Rights Reserved.115/27/2012
12
Data Representation How many characters do we need to represent? A thru Z – 26 characters 0 thru 9 – 10 characters 36 – minimum of 6 bits BCD – B inary C oded D ecimal © John Urrutia 2012, All Rights Reserved.125/27/2012
13
Data Representation What about the lower case alphabet & punctuation? a thru z – 26 characters !@#$%^&*()-_+=[] \{}|;’:”,./<>?`~ – 32 characters Total - 88 characters – minimum 7 bits EBCDIC – E xtended B inary C oded D ecimal I nterchange C ode © John Urrutia 2012, All Rights Reserved.135/27/2012
14
Data Representation © John Urrutia 2012, All Rights Reserved.145/27/2012
15
Data Representation Now we have the code so write your first name based on the binary code below. © John Urrutia 2012, All Rights Reserved.155/27/2012 CharCodeCharCodeCharCodeCharCode A 11000001 H 11001000 O 11010110 V 11100101 B 11000010 I 11001001 P 11010111 W 11100110 C 11000011 J 11010001 Q 11011000 X 11100111 D 11000100 K 11010010 R 11011001 Y 11101000 E 11000101 L 11010011 S 11010010 Z 11101001 F 11000110 M 11010100 T 11100011 G 11000111 N 11010101 U 11100100
16
Data Representation Hi! My Name is: 11010001110101101100100011010101 Difficult to communicate??? Hexadecimal to the rescue Hi! My Name is: D1D6C8D5 © John Urrutia 2012, All Rights Reserved.165/27/2012
17
Data Representation High Order - Nibble Zone Low Order - Nibble Digit © John Urrutia 2012, All Rights Reserved.175/27/2012 1101 0001 D1
18
Data Representation Zoned-Decimal Format Used primarily to store printable characters Packed Format Used primarily for decimal arithmetic Binary Format © John Urrutia 2012, All Rights Reserved.185/27/2012 1234 F1F2F3F4 1234 0001234F 1234 000004D2
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.