Presentation is loading. Please wait.

Presentation is loading. Please wait.

CDP ECE 291 -- Spring 2000 ECE 291 Spring 2000 Lecture 2: Number Systems & x86 Instructions Constantine D. Polychronopoulos Professor, ECE Office: 463.

Similar presentations


Presentation on theme: "CDP ECE 291 -- Spring 2000 ECE 291 Spring 2000 Lecture 2: Number Systems & x86 Instructions Constantine D. Polychronopoulos Professor, ECE Office: 463."— Presentation transcript:

1 CDP ECE 291 -- Spring 2000 ECE 291 Spring 2000 Lecture 2: Number Systems & x86 Instructions Constantine D. Polychronopoulos Professor, ECE Office: 463 CSRL

2 CDP ECE 291 -- Spring 2000 Number Systems - Review ECE 290!! Decimal numbers (or base 10 system) - Notation: 0,1,…9: –Example: 378 = 3 * 10 2 + 7 * 10 1 + 8 * 10 0 Binary numbers (or base 2 system) - Notation: 0 and 1: –Example: (001101) 2 = 1 * 2 3 + 1 * 2 2 + 0 * 2 1 + 1 * 2 0 = 8+4+1=(13) 10 Hexadecimal numbers (or base 16 system) - Notation: 0..9,A,B,C,D,E,F: –Example: 52A4F = 5*16 4 + 2*16 3 + 10*16 2 + 4*16 1 + 15*16 0 Many other representations –BCD (Binary Coded Decimal): decimal numbers represented in binary notation with each decimal digit represented by its 4-bit binary encoding: Example: 728 in BCD is 0111 0010 1000

3 CDP ECE 291 -- Spring 2000 Base Conversion Always easy to convert from any base b to decimal: just compute the sum of products - result is in decimal. Converting from decimal to base b: Successive division or (remainder) decimal with the largest power of b - successive quotients form base b representation. –Example: Convert 77 to binary representation. Divide 77 by 64 (2 6 ) - Q = 1 R=13 Divide 13 by 8 (2 3 ) - Q = 1 R=5 Divide 5 by 4 (2 2 ) - Q = 1 R=1 Divide 1 by 1 (2 0 ) - Q = 1 R=0 --- DONE –Result: 77 = 1 0 0 1 1 0 1 –Put 1’s where Q=1 and 0’s in the remaining positions

4 CDP ECE 291 -- Spring 2000 Converting Fractional Part 1- Multiply fraction with base 2- Save integer digit (if any) 3- Repeat until remainder=0 or accuracy is obtained 4- The successive digits form the converted fractional representation –Example: Converting.173 to octal representation.173 X 8 = 1.384 Save 1.384 X 8 = 3.072 Save 3.072 X 8 = 0.576 Save 0 –.173 in base 10 =.130… octal

5 CDP ECE 291 -- Spring 2000 Radix-1 & Radix Complement Representation One’s complement representation: –Subtract n-bit binary representation from n-bit all 1’s (radix-1) Two’s complement representation: –As in One’s complement + add 1 to the result (radix) One of the problem with (radix-1) complement representation is inability to uniquely represent zero. Two’s complement gives you the inverted (negated) number: if you add a number and its (radix) complement discarding any overflow, the result is ZERO!

6 CDP ECE 291 -- Spring 2000 Signed & Unsigned Representations First bit in binary rep. is sign bit: –s=0: positive (+) –s=1: negative (-) Two quick schemes to represent a negative number N (any of them will work): –Invert all bits then add 1 (2’s complement) –Scan N from right to left: copy 0’s, copy first 1, invert the rest Sign-extending a number: copy sign bit into extra leftmost positions

7 CDP ECE 291 -- Spring 2000 Memory Objects & Data Types Data Types Numbers bit (eg: 1) nibble = 4 bits DB:byte = octet = 8 bits DW:Word = 2 bytes = 16 bits (80x86 terminology) DD:DoubleWord = 4 bytes = 32 bits (80x86 terminology) Intel uses little endian format (i.e., LSB at lower address) Signed Integers (2's complement)

8 CDP ECE 291 -- Spring 2000 Memory Objects (Cont.) Text Letters and characters (7-bit ASCII standard) 'A'=65=0x41 Extended ASCII (8-bit) allows for extra 128 graphics/symbols) Collection of characters = Strings Collection of Strings = Documents Programs Commands (MOV, JMP, AND, OR, NOT) Collections of commands = procedures/functions/subroutines Collection of subroutines = programs

9 CDP ECE 291 -- Spring 2000 Memory Objects (Cont.) Floating point numbers (covered later) Images (GIF, TIF, JPG, BMP) Video (MPEG, QuickTime, AVI) Audio (voice, music)


Download ppt "CDP ECE 291 -- Spring 2000 ECE 291 Spring 2000 Lecture 2: Number Systems & x86 Instructions Constantine D. Polychronopoulos Professor, ECE Office: 463."

Similar presentations


Ads by Google