Вы находитесь на странице: 1из 32

MACHINE LEVEL REPRESENTATION OF DATA

Fundamentals of Computer and programming in C (CMP 101 )

Representing Information in Computers


All the different type of information in computers can be represented using binary codes. Numbers Letters of alphabets and punctuation marks Microprocessor instructions Graphics/Videos Sounds
13-04-2012 http://in.groups.yahoo.com/group/shardaf undamental

Bits, Bytes, and Words


A bit is a single binary digit (a 1 or 0). A byte is 8 bits A word is 32 bits or 4 bytes Long word = 8 bytes = 64 bits Quad word = 16 bytes = 128 bits Programming languages use these standard number of bits when organizing data storage and access.

13-04-2012

http://in.groups.yahoo.com/group/shardaf undamental

Data Representation Standards


Specified standards for representing data in computer memory. Standard are arbitrary They exist because they are
Convenient Efficient Flexible Appropriate Etc.
13-04-2012 http://in.groups.yahoo.com/group/shardaf undamental

Alphanumeric Data
Problem: Distinguishing between the number 123 (one hundred and twenty-three) and the characters 123 (one, two, three) Four standards for representing letters (alpha) and numbers
BCD Binary-coded decimal ASCII American standard code for information interchange EBCDIC Extended binary-coded decimal interchange code Unicode

13-04-2012

http://in.groups.yahoo.com/group/shardaf undamental

Computer Codes
Data types

Numeric

Nonnumeric

Integer

Real

Alphabet A, B, C, ,Z a, b, c,,z

Digits 0,,9

13-04-2012

http://in.groups.yahoo.com/group/shardaf undamental

Special Characters +,-, /, *,~,`,!, @, #,$,%, ^, &, (, ),_ =, <, >, :,;,., [,],{, },

Computer Codes
Any data is internally represented using bits (0 and 1) Computer codes were invented by grouping the bits to represent the data types A group consisting of n bits was called n-bitbyte. The group size is standardized to 8-bits. Now a byte means a group of 8-bits.
http://in.groups.yahoo.com/group/shardaf undamental

13-04-2012

Standard Alphanumeric Formats


BCD ASCII EBCDIC Unicode
Next 2 slides

13-04-2012

http://in.groups.yahoo.com/group/shardaf undamental

Binary-Coded Decimal (BCD)


Four bits per digit
Note: the following bit patterns are not used: 1010 1011 1100 1101 1110 1111

Digit 0 1 2

Bit pattern 0000 0001 0010

3
4 5 6 7

0011
0100 0101 0110 0111

8
9
13-04-2012 http://in.groups.yahoo.com/group/shardaf undamental

1000
1001

Example
709310 = ? (in BCD)
7 0 9 3

0111

0000

1001

0011

13-04-2012

http://in.groups.yahoo.com/group/shardaf undamental

Standard Alphanumeric Formats


BCD ASCII EBCDIC Unicode
Next 22 slides

13-04-2012

http://in.groups.yahoo.com/group/shardaf undamental

The Problem
Representing text strings, such as Hello, world, in a computer

13-04-2012

http://in.groups.yahoo.com/group/shardaf undamental

Codes and Characters


Each character is coded as a byte Most common coding system is ASCII (Pronounced ass-key) ASCII = American National Standard Code for Information Interchange Defined in ANSI document X3.4-1977

13-04-2012

http://in.groups.yahoo.com/group/shardaf undamental

ASCII Features
7-bit code 8th bit is unused (or used for a parity bit) 27 = 128 codes Two general types of codes:
95 are Graphic codes (displayable on a console) 33 are Control codes (control features of the console or communications channel)

13-04-2012

http://in.groups.yahoo.com/group/shardaf undamental

ASCII Chart
0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 000 NULL SOH STX ETX EDT ENQ ACK BEL BS HT LF VT FF CR SO SI 001 DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US 010 ! " # $ % & ' ( ) * + , . / 011 0 1 2 3 4 5 6 7 8 9 : ; < = > ? 100 @ A B C D E F G H I J K L M N O 101 P Q R S T U V W X Y Z [ \ ] ^ _ 110 ` a b c d e f g h i j k l m n o 111 p q r s t u v w x y z { | } ~ DEL

13-04-2012

http://in.groups.yahoo.com/group/shardaf undamental

000 001 0000 NULL DLE 0001 SOH DC1 0010 STX DC2 0011 ETX DC3 0100 EDT DC4 0101 ENQ NAK 0110 ACK SYN 0111 BEL ETB 1000 BS CAN 1001 HT EM 1010 LF SUB 1011 VT Least significantESC bit 1100 FF FS 1101 CR GS 1110 SO RS 1111 SI US

011 0 ! 1 " 2 # 3 Most significant bit $ 4 % 5 & 6 ' 7 ( 8 ) 9 * : + ; , < = . > / ?

010

100 @ A B C D E F G H I J K L M N O

101 P Q R S T U V W X Y Z [ \ ] ^ _

110 ` a b c d e f g h i j k l m n o

111 p q r s t u v w x y z { | } ~ DEL

13-04-2012

http://in.groups.yahoo.com/group/shardaf undamental

e.g., a = 1100001

0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111

000 NULL SOH STX ETX EDT ENQ ACK BEL BS HT LF VT FF CR SO SI

001 DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US

010 ! " # $ % & ' ( ) * + , . /

011 0 1 2 3 4 5 6 7 8 9 : ; < = > ?

100 @ A B C D E F G H I J K L M N O

101 P Q R S T U V W X Y Z [ \ ] ^ _

110 ` a b c d e f g h i j k l m n o

111 p q r s t u v w x y z { | } ~ DEL

13-04-2012

http://in.groups.yahoo.com/group/shardaf undamental

95 Graphic codes

0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111

000 NULL SOH STX ETX EDT ENQ ACK BEL BS HT LF VT FF CR SO SI

001 DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US

010 ! " # $ % & ' ( ) * + , . /

011 0 1 2 3 4 5 6 7 8 9 : ; < = > ?

100 @ A B C D E F G H I J K L M N O

101 P Q R S T U V W X Y Z [ \ ] ^ _

110 ` a b c d e f g h i j k l m n o

111 p q r s t u v w x y z { | } ~ DEL

13-04-2012

http://in.groups.yahoo.com/group/shardaf undamental

33 Control codes

0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111

000 NULL SOH STX ETX EDT ENQ ACK BEL BS HT LF VT FF CR SO SI

001 DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US

010 ! " # $ % & ' ( ) * + , . /

011 0 1 2 3 4 5 6 7 8 9 : ; < = > ?

100 @ A B C D E F G H I J K L M N O

101 P Q R S T U V W X Y Z [ \ ] ^ _

110 ` a b c d e f g h i j k l m n o

111 p q r s t u v w x y z { | } ~ DEL

13-04-2012

http://in.groups.yahoo.com/group/shardaf undamental

Alphabetic codes

0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111

000 NULL SOH STX ETX EDT ENQ ACK BEL BS HT LF VT FF CR SO SI

001 DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US

010 ! " # $ % & ' ( ) * + , . /

011 0 1 2 3 4 5 6 7 8 9 : ; < = > ?

100 @ A B C D E F G H I J K L M N O

101 P Q R S T U V W X Y Z [ \ ] ^ _

110 ` a b c d e f g h i j k l m n o

111 p q r s t u v w x y z { | } ~ DEL

13-04-2012

http://in.groups.yahoo.com/group/shardaf undamental

Numeric codes

0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111

000 NULL SOH STX ETX EDT ENQ ACK BEL BS HT LF VT FF CR SO SI

001 DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US

010 ! " # $ % & ' ( ) * + , . /

011 0 1 2 3 4 5 6 7 8 9 : ; < = > ?

100 @ A B C D E F G H I J K L M N O

101 P Q R S T U V W X Y Z [ \ ] ^ _

110 ` a b c d e f g h i j k l m n o

111 p q r s t u v w x y z { | } ~ DEL

13-04-2012

http://in.groups.yahoo.com/group/shardaf undamental

Punctuation, etc.

0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111

000 NULL SOH STX ETX EDT ENQ ACK BEL BS HT LF VT FF CR SO SI

001 DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US

010 ! " # $ % & ' ( ) * + , . /

011 0 1 2 3 4 5 6 7 8 9 : ; < = > ?

100 @ A B C D E F G H I J K L M N O

101 P Q R S T U V W X Y Z [ \ ] ^ _

110 ` a b c d e f g h i j k l m n o

111 p q r s t u v w x y z { | } ~ DEL

13-04-2012

http://in.groups.yahoo.com/group/shardaf undamental

Hello, world Example


Binary 01001000 01100101 01101100 01101100 01101111 00101100 00100000 01110111 01100111 01110010 01101100 01100100 Hexadecimal 48 65 6C 6C 6F 2C 20 77 67 72 6C 64 Decimal 72 101 108 108 111 44 32 119 103 114 108 100

H e l l o , w o r l d

= = = = = = = = = = = =

= = = = = = = = = = = =

= = = = = = = = = = = =

13-04-2012

http://in.groups.yahoo.com/group/shardaf undamental

Common Control Codes


CR LF HT DEL NULL 0D 0A 09 7F 00 carriage return line feed horizontal tab delete null

Hexadecimal code

13-04-2012

http://in.groups.yahoo.com/group/shardaf undamental

0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111

000 NULL SOH STX ETX EDT ENQ ACK BEL BS HT LF VT FF CR SO SI

001 DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US

010 ! " # $ % & ' ( ) * + , . /

011 0 1 2 3 4 5 6 7 8 9 : ; < = > ?

100 @ A B C D E F G H I J K L M N O

101 P Q R S T U V W X Y Z [ \ ] ^ _

110 ` a b c d e f g h i j k l m n o

111 p q r s t u v w x y z { | } ~ DEL

13-04-2012

http://in.groups.yahoo.com/group/shardaf undamental

Terminology
Learn the names of the special symbols
[] {} () @ & ~ brackets braces parentheses commercial at sign ampersand tilde

13-04-2012

http://in.groups.yahoo.com/group/shardaf undamental

0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111

000 NULL SOH STX ETX EDT ENQ ACK BEL BS HT LF VT FF CR SO SI

001 DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US

010 ! " # $ % & ' ( ) * + , . /

011 0 1 2 3 4 5 6 7 8 9 : ; < = > ?

100 @ A B C D E F G H I J K L M N O

101 P Q R S T U V W X Y Z [ \ ] ^ _

110 ` a b c d e f g h i j k l m n o

111 p q r s t u v w x y z { | } ~ DEL

13-04-2012

http://in.groups.yahoo.com/group/shardaf undamental

Standard Alphanumeric Formats


BCD ASCII EBCDIC Unicode

Next 1 slides

13-04-2012

http://in.groups.yahoo.com/group/shardaf undamental

EBCDIC
Extended BCD Interchange Code (pronounced ebb-se-dick) 8-bit code Developed by IBM Rarely used today IBM mainframes only

13-04-2012

http://in.groups.yahoo.com/group/shardaf undamental

Standard Alphanumeric Formats


BCD ASCII EBCDIC Unicode

Next 2 slides

13-04-2012

http://in.groups.yahoo.com/group/shardaf undamental

Unicode
16-bit standard Developed by a consortia Intended to supercede older 7- and 8-bit codes

13-04-2012

http://in.groups.yahoo.com/group/shardaf undamental

Unicode Version 2.1


1998 Improves on version 2.0 Includes the Euro sign (20AC16 = From the standard:

contains 38,887 distinct coded characters derived from the supported scripts. These characters cover the principal written languages of the Americas, Europe, the Middle East, Africa, India, Asia, and Pacifica. http://www.unicode.org
http://in.groups.yahoo.com/group/shardaf undamental

13-04-2012

Вам также может понравиться