Data Representation: Computer Organization & Assembly Language Programming DR Adnan Gutub Aagutub At' Uqu - Edu.sa
Data Representation: Computer Organization & Assembly Language Programming DR Adnan Gutub Aagutub At' Uqu - Edu.sa
Computer Organization
&
Assembly Language Programming
Dr Adnan Gutub
aagutub ‘at’ uqu.edu.sa
[Adapted from slides of Dr. Kip Irvine: Assembly Language for Intel-Based Computers]
Most Slides contents have been arranged by Dr Muhamed Mudawar & Dr Aiman El-Maleh from Computer Engineering Dept. at KFUPM
Outline
Introduction
Numbering Systems
Binary & Hexadecimal Numbers
Base Conversions
Integer Storage Sizes
Binary and Hexadecimal Addition
Signed Integers and 2's Complement Notation
Binary and Hexadecimal subtraction
Carry and Overflow
Character Storage
Data Representation Computer Organization and Assembly Language
slide 2/33
Introduction
Computers only deal with binary data (0s and 1s), hence all data
manipulated by computers must be represented in binary format.
Machine instructions manipulate many different forms of data:
Numbers:
Integers: 33, +128, -2827
Real numbers: 1.33, +9.55609, -6.76E12, +4.33E-03
Alphanumeric characters (letters, numbers, signs, control characters):
examples: A, a, c, 1 ,3, ", +, Ctrl, Shift, etc.
Images (still or moving): Usually represented by numbers representing
the Red, Green and Blue (RGB) colors of each pixel in an image,
Sounds: Numbers representing sound amplitudes sampled at a certain
rate (usually 20kHz).
So in general we have two major data types that need to be
represented in computers; numbers and characters.
stop when
37 = 100101 quotient is zero
Data Representation Computer Organization and Assembly Language
slide 7/33
Another Procedure for Converting from
Decimal to Binary
Start with a binary representation of all 0’s
Determine the highest possible power of two that is less
or equal to the number.
Put a 1 in the bit position corresponding to the highest
power of two found above.
Subtract the highest power of two found above from the
number.
Repeat the process for the remaining number
M1023.swf
M1021.swf
stop when
quotient is zero
Standard sizes:
carry: 1
0 0 0 0 0 1 0 0 (4)
+ 0 0 0 0 0 1 1 1 (7)
0 0 0 0 1 0 1 1 (11)
bit position: 7 6 5 4 3 2 1 0
1 1
36 28 28 6A
42 45 58 4B
78 6D 80 B5
21 / 16 = 1, remainder 5
Examples:
2's complement of 6A3D = 95C3
2's complement of 92F0 = 6D10
2's complement of FFFF = 0001
16 + 5 = 21
-1 11
C675 C675
- +
A247 5DB9 (2's complement)
242E 242E (same result)
0 0 0 0 1 1 1 1 15 0 0 0 0 1 1 1 1 15
+ +
0 0 0 0 1 0 0 0 8 1 1 1 1 1 0 0 0 245 (-8)
0 0 0 1 0 1 1 1 23 0 0 0 0 0 1 1 1 7
1 1 1 1
0 1 0 0 1 1 1 1 79 1 1 0 1 1 0 1 0 218 (-38)
+ +
0 1 0 0 0 0 0 0 64 1 0 0 1 1 1 0 1 157 (-99)
1 0 0 0 1 1 1 1 143 0 1 1 1 0 1 1 1 119
(-113)
Carry = 0 Overflow = 1 Carry = 1 Overflow = 1
Data Representation Computer Organization and Assembly Language
slide 29/33
Character Storage
Character sets
Standard ASCII: 7-bit character codes (0 – 127)
Extended ASCII: 8-bit character codes (0 – 255)
Unicode: 16-bit character codes (0 – 65,535)
Unicode standard represents a universal character set
Defines codes for characters used in all major languages
Used in Windows-XP: each character is encoded as 16 bits
UTF-8: variable-length encoding used in HTML
Encodes all Unicode characters
Uses 1 byte for ASCII, but multiple bytes for other characters
Null-terminated String
Array of characters followed by a NULL character
Data Representation Computer Organization and Assembly Language
slide 30/33
ASCII Codes
Examples:
ASCII code for space character = 20 (hex) = 32 (decimal)
ASCII code for ‘A' = 41 (hex) = 65 (decimal)
ASCII code for 'a' = 61 (hex) = 97 (decimal)
Data Representation Computer Organization and Assembly Language
slide 31/33
Control Characters
The first 32 characters of ASCII table are used for control
Control character codes = 00 to 1F (hex)
Examples of Control Characters
Character 0 is the NULL character used to terminate a string
Character 9 is the Horizontal Tab (HT) character
Character 0A (hex) = 10 (decimal) is the Line Feed (LF)
Character 0D (hex) = 13 (decimal) is the Carriage Return (CR)
The LF and CR characters are used together
They advance the cursor to the beginning of next line
Odd Parity: The 8th bit is set such that the total number of 1s in
the 8-bit code word is odd.