
Course Schedule W1 Sep 11- Sep 14 Introduction W2 Sep 18- Sep 21 Information Representation (1) (Chapter 3) W3 Sep 25- Sep 28 Information Representation (2) (Chapter 3) W4 Oct 2- Oct 5 Computer Architecture Pep/6 (Chapter 4) CS 221 Computer Architecture W5 Oct 9- Oct 12 Assembly Language (Chapter 5) W6* Oct 16- Oct 19 High-Level Languages (1) (Chapter 6) W7* Oct 23- Oct 26 High-Level Languages (2) (Chapter 6) Week 3: Information Representation (2) Midterm* W8 Oct 30- Nov 2 Instruction Sets (Tanenbaum) Fall 2001 W9 Nov 6 - Nov 9 Devices & Interrupts (Chapter 8) W10* Nov 13- Nov 16Storage Management (Chapter 9) W11 Nov 20- Nov 23 Combinational Logic (Chapter 10) W12 Nov 27- Nov 30 Sequential Logic & Review (Chapter 11) *Marked classes will be taught by Dave Dove, same place same slot CISC 221 Fall 2001 Week 3 1 CISC 221 Fall 2001 Week 3 2 Week 3: Plan • Hexadecimal Representation • Character Representation I. • Floating Point Representation Hexadecimals and Character Representations • Introduction to PEP/6 • Readings – Chapter 3 of book – Next week: Chapter 4 (please start reading!) CISC 221 Fall 2001 Week 3 3 CISC 221 Fall 2001 Week 3 4 Hexadecimal Representation Remember the Octal System • Binary numbers are hard to read for humans. 0 10 (8) ... 70 (7*8 = 56) … 100 (8*8 = 64) • Hexadecimal and octal notations are just two 11171 different choices of the base in a weighted radix 21272 position number system. 31373 41474 • Hexadecimal is base 16, and octal base 8. 51575 61676 7 17 (15) 77 This is called the octal system of counting or base 8 101 = 1 x 82 + 0 x 81 + 1 x 80 = 65 CISC 221 Fall 2001 Week 3 5 CISC 221 Fall 2001 Week 3 6 1 Hexadecimal System So Why Hexadecimal? 0 10 (16) ... F0 (15*16 = 240) … 100 (16*16 = 256) • Hexadecimal and Octal are useful because 111 – They are easier for people to deal with than a strict 21272 31373 binary representation: a shorthand. 41474 – Because the bases are powers of two, the digits in 51575 hexadecimal and octal representations map straight 61676 onto groups of bits in the binary representation. 7 17 • Each hexadecimal digit corresponds to 4 binary 8 18 For decimal 10 through 15, we use A to F 9 19 This is called the hexadecimal system bits or a nibble A 1A or base 16 – Each octal digit corresponds to 3 binary bits. B1B 0111 1111 binary 1010 1000 binary C1C 101 = 1 x 162 + 0 x 161 + 1 x 160 = 257 D1D 7 F hex A 8 hex E1E • It is easy to remember the binary nibble patterns F 1F (31) that correspond to a hexadecimal character! CISC 221 Fall 2001 Week 3 7 CISC 221 Fall 2001 Week 3 8 Example From Decimal to Hex • F00D is a hexadecimal number • Divide the number by 16, the base, and write down the remainder. • F00D 15 * 163 + 0 * 162 + 0 * 161+ 13 * 160 = 4313 / 16 remainder 15*4096 + 0*256 + 0*16 + 13 = 61453 269 9 16 d by now we have divided by 162 • However, to convert hexadecimal into binary, just 1 0 by now we have divided by 163 convert each hex digit into 4 bits: 0 1 by now we have divided by 164 – F00D is 1111 0000 0000 1101 – The sign of a hex constant in 2’s complement is indicated by the value of the most significant bit. • Now read back in reverse order: 10d9! – FOOD is negative because 'f' represents a bit • Use hex as intermediate when converting to binary pattern greater than or equal to 8. 10d9 hex is 0001 0000 1101 1001 in binary! CISC 221 Fall 2001 Week 3 9 CISC 221 Fall 2001 Week 3 10 Representing Characters ASCII Table • Since all data are represented as bits, we need to encode characters as binary numbers. • Assignment of values to the chars can be arbitrary – But use of arithmetic comparisons of the codes should be possible to do alphabetical sorting. • ASCII (American Standard Code for Information Interchange) is the most common code. – Encodes letters used in English, punctuation marks, and some control characters into 7 bit numbers. – However, typically a full byte is used for convenience, leaving the msb empty. CISC 221 Fall 2001 Week 3 11 CISC 221 Fall 2001 Week 3 12 2 Other Coding Schemes • There are standards to extend ASCII to include characters from more alphabets: – Characters are commonly stored one per 8-bit byte, which gives you another bit to play with. – ISO-8859-x series codes the first 128 characters II. the same as ASCII, and the upper 128 characters Floating Point Representations are different sets of special symbols and accented characters from various Roman alphabets. – ISO 8859-1 is called "Latin One". • Unicode is a 16-bit encoding that represents scripts for all the alphabets in the world. – Char types in Java use Unicode. – The least significant 8 bits of Unicode encodings are compatible with ISO-8859 and thus ASCII. CISC 221 Fall 2001 Week 3 13 CISC 221 Fall 2001 Week 3 14 Announcements So we haven’t discussed fractions! • There will be an extra tutorial on PEP/6 this Friday • So how do we represent fractions in binary? • Details will follow – We can’t use any of the schemes we’ve used so far. – Because they can only represent powers of 2. • But instead of interpreting binary numbers using positive exponents like 2n • We could interpret them as negative exponents: 2-n !! 1010 = 1*2-1 + 0*2-2 + 1*2-3 + 0*2-4 1 * 1/2 + 0* 1/4 + 1*1/8 + 0*1/16 = .625 CISC 221 Fall 2001 Week 3 15 CISC 221 Fall 2001 Week 3 16 Fractions in Decimal Negative Fractions in Binary • Note that this works like decimal scientific notation • So how do we represent negative numbers? 12.4568 (decimal) means – Simple: use 20 (=1). 1*101 + 2*100 + 4*10-1 + 5*10-2 + 6*10-3 + 8*10-4 = – It’s the MSB, and we can use it as a sign bit. 1*10 + 2*1 + 4/10 + 5/100 + 6/1000 + 8/10000 – So our original bit pattern should have been: • In scientific notation: 12.4568 = 01010 = - 0*20 + 1*2-1 + 0*2-2 + 1*2-3 + 0*2-4 1245680 * 10-5 = 0 + 1 * 1/2 + 0* 1/4 + 1*1/8 + 0*1/16 = .625 -4 124568 * 10 = or 1245.68 * 10-2 = 124.568 * 10-1 = 11010 = -1 + 1 * 1/2 + 0* 1/4 + 1*1/8 + 0*1/16 = – .375 1.24568 * 101 (this is called normalized notation) • Our notation now is called Fixed Point notation CISC 221 Fall 2001 Week 3 17 CISC 221 Fall 2001 Week 3 18 3 Floating Point Notation Floating Point Notation (2) • Note that we could have put the decimal point at • The alternative would be to have a limited any arbitrary location and make it a standard. precision: we could not represent all numbers. – However, it would be fixed after that. – Note that we can never represent all fractions! – Which is why it is called fixed point • Or have a floating point, where we could adjust • However, scientific calculations often involve very precision according to our needs. small as well as very large numbers. – Scientific decimal notation actually does this. – Would be neat if one number could represent – A number is represented by a fraction or mantissa The mass of the sun: 2 * 10 33 grams which corresponds to the precision of the value. The mass of an electron: 9 * 10 -28 grams – The fraction is multiplied by ten raised to the power – We would need a lot of bits for this in fixed point. of a specified exponent (e below): To write them both out as complete decimal fractions that you could line up for e addition would require 62 decimal digits (34 before the decimal point and 28 after x = f * 10 it). Yet each number has only one significant digit, so the 64 digit representation would store a great many 0s. where f is the fraction or mantissa and e is the exponent CISC 221 Fall 2001 Week 3 19 CISC 221 Fall 2001 Week 3 20 So what exponent do we use? Floating Point in Binary (2) • Where do we put the decimal point? • Floating Points in binary work the same as in • In scientific notation, fractions are normalized decimal, except the base is 2 rather then 10 – the exponent is adjusted so that there is one digit to the left of the decimal point. x = f * 2e where f is the fraction and e is the exponent 12.4568 = 23456.78 (2.345678 * 104) decimal corresponds to 1245680 * 10-5 = 124568 * 10-4 = 23456 . 78 1245.68 * 10-2 = 101101110100000.110001111010 * 20 = 124.568 * 10-1 = and then we normalize by shifting right 1 1.24568 * 10 (normalized notation) 1.01101110100000110001111010 * 214= 214 *(0* 2-1 + 1*2-2 … + 0* 2-27) • So write 2.345678 * 104 rather than 23.45678 * 103 CISC 221 Fall 2001 Week 3 21 CISC 221 Fall 2001 Week 3 22 Conversion to Binary: Whole part Conversion to Binary: Fraction • How do you convert from decimal fractions to • How do you convert the fractional part? binary ones? Repeatedly multiply the fraction by two. Convert the When the result is whole number greater than or part using familiar equal to one, method of repeated subtract one from divisions & the product and remainders record a one in the corresponding bit position.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages9 Page
-
File Size-