Presentation is loading. Please wait.

Presentation is loading. Please wait.

Assembly Language for Intel-Based Computers

Similar presentations


Presentation on theme: "Assembly Language for Intel-Based Computers"— Presentation transcript:

1 Assembly Language for Intel-Based Computers
DATA REPRESENTATION Part 1

2 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

3 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 Input device A 1+2=3 math

4 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

5 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

6 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)

7 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

8 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: " " ASCII decimal string of digits: "65" ASCII hexadecimal string of digits: "9C"

9 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

10 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

11 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

12 Binary, Octal, Decimal and Hexadecimal Digits Table
System Base Possible Digits Binary 2 0 1 Octal 8 Decimal 10 Hexadecimal 16 A B C D E F

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

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

15 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

16 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 = decimal 9: How to calculate? ( 0 27)+(0  26)+(0  25)+(0  24)+(1  23)+(0  22)+ (0  21)+ (1  20)  9

17 Translating Binary to Decimal
Try this

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

19 Translating Decimal to Binary
Try this 55 16 77 111

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

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

22 Hexadecimal Integers Binary values are represented in hexadecimal.

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

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

25 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.

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

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

28 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 B8 21/16 = 1, remain 5 1/16 = 0, remain 1 Important skill: Programmers frequently add and subtract the addresses of variables and instructions.

29 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

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

31 Hexadecimal Subtraction
7 5 4 7 2 E = 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

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

33 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

34 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)

35 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: = +255 Signed: = = -127 Note: 2 values for 0: +0 ( ) and -0 ( )

36 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

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

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

39 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

40 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

41 **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

42 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?

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

44 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 (First complement) (Two’s Complement) =( 1 X 2 ^ 5) =16 =16

45 Learn How To Do the Following:
Convert signed decimal to binary - 43 =? 43= Two’s Complement: Convert signed decimal to hexadecimal -18 =? * Twist 18=12 hexadecimal Two’s complement: 15 15 E D E E

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


Download ppt "Assembly Language for Intel-Based Computers"

Similar presentations


Ads by Google