15
Data Representation and Storage 1. Algorithms tell processors how to manipulate data TRANS 2. Architecture versus Organization ... a question of detail CS has courses in both 3. The Progression: Chapter 1 ... we study how data is represented and stored Chapter 2 ... we study how a processor can manipulate data Chapter 3 … we study the kinds of programs that control the processor ... the Operating System. Chapter 4 ... we study the algorithms that instruct the processor in the solution of problems 4. We want to represent human knowledge in a computer Numbers (this was the goal of the earliest computers) Words (ideas … humans use written language to represent ideas) Images Sounds Smell Other? 5. BINARY codes … easier to build devices ON / OFF(transistor) CHARGED / UNCHARGED (capacitor) N-POLE / S-POLE (magnetic disk or tape) REFLECTED LIGHT / SCATTERED LIGHT (CDROM) 0 / 1 ... to represent the two states ... no meaning in themselves

Data Representation and Storagejupiter.plymouth.edu/~wjt/Foundations/Lectures/DataRepresentation-old.pdf30 1E US Unit Separator 31 1F 00011111 DEL Delete . Title: Data Representation.PDF

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Data Representation and Storagejupiter.plymouth.edu/~wjt/Foundations/Lectures/DataRepresentation-old.pdf30 1E US Unit Separator 31 1F 00011111 DEL Delete . Title: Data Representation.PDF

Data Representation and Storage 1. Algorithms tell processors how to manipulate data TRANS 2. Architecture versus Organization ... a question of detail

• CS has courses in both 3. The Progression:

• Chapter 1 ... we study how data is represented and stored • Chapter 2 ... we study how a processor can manipulate data • Chapter 3 … we study the kinds of programs that control the

processor ... the Operating System. • Chapter 4 ... we study the algorithms that instruct the processor in

the solution of problems 4. We want to represent human knowledge in a computer

• Numbers (this was the goal of the earliest computers) • Words (ideas … humans use written language to represent ideas) • Images • Sounds • Smell • Other?

5. BINARY codes … easier to build devices

• ON / OFF (transistor) • CHARGED / UNCHARGED (capacitor) • N-POLE / S-POLE (magnetic disk or tape) • REFLECTED LIGHT / SCATTERED LIGHT (CDROM) • 0 / 1 ... to represent the two states ... no meaning in themselves

William J Taffe
Page 2: Data Representation and Storagejupiter.plymouth.edu/~wjt/Foundations/Lectures/DataRepresentation-old.pdf30 1E US Unit Separator 31 1F 00011111 DEL Delete . Title: Data Representation.PDF

6. ASCII Code ... binary representation of keyboard • Tables represent char, decimal equivalent TRANS • Can represent all “western” alphabet characters … 8-bit → 256

chars • See Appendix A in the text for the full code • Sometimes in hexadecimal or octal … sometimes only given by 7

bits • Codes 0..31 represent “nonprintable” ASCII control characters …

print “weird” things on the screen TRANS 7. Uniode … the “modern”, international representational code

• 16-bit → 65,536 chars … able to include all alphabets and scripts used today.

• Java uses unicode • First 8 bits (256 char) are the same as ASCII

8. Other Codes

• BCD ... Binary Coded Decimal ... just for numbers and capital letters

• EBCDIC Extended BCD for Information ??? (IBM Mainframes only)

9. Sequence of events from striking a key (eg. The letter “A” or the

number “1”) to storage and use in a computer

William J Taffe
William J Taffe
Page 3: Data Representation and Storagejupiter.plymouth.edu/~wjt/Foundations/Lectures/DataRepresentation-old.pdf30 1E US Unit Separator 31 1F 00011111 DEL Delete . Title: Data Representation.PDF

10. Binary representation of our decimal numbers

Binary 0 = 010 1 = 110

but there is no 2 in binary ... only 0 and 1 Decimal Binary 0 0000 1 0001 2 0010 3 0011 4 0100 etc. 100 = 1 20 = 1 101 = 10 21 = 2 102 = 100 22 = 4

Concept of Place Value • 0's place, 1's place, 2's place, etc • Therefore 7326 = 7X103 + 3X102 + 2X101 + 6X100 • 1101 = 1X23 + 1X22 + 0X21 + 1X20 = 8 + 4 + 0 + 1 = 13

11. Binary ⇔ Decimal Conversions

• Examples using concept of place value for binary numbers … see text also.

Page 4: Data Representation and Storagejupiter.plymouth.edu/~wjt/Foundations/Lectures/DataRepresentation-old.pdf30 1E US Unit Separator 31 1F 00011111 DEL Delete . Title: Data Representation.PDF

BINARY is hard on the eyes ... therefore we use decimal or hexadecimal to represent binary ... hex is easier

Decimal BINARY HEX 00 00000000 00 01 00000001 01 02 00000010 02 ... ... ... 09 00001001 09 10 00001010 0A … 14 00001110 0E 15 00001111 0F 16 00010000 10 17 00010001 11 ... 31 00011111 1F 32 00100000 20 33 00100001 21

12. Memory cells ... bit, byte, word ... define

• Modern cells store one byte 13. Computers use electrical, and magnetic and optical methods for

storing data. Previously we also used punched cards, paper tape and other devices but electrical, magnetic and optical methods are faster. • Primary memory ... electrical ... Cache, RAM, ROM • Secondary memory ... disk, CDROM, tape

14. Cell has an address and content ... Post Office analogy TRANS • RAM, ROM, Cache ... follow the post office box analogy

15. Hard disk, floppy disk TRANS • Tracks and sectors • Floppy disk holds 1.4 MB (high density) • (Our text ... 80 char/line X 40 lines/page X 600 pages =

1,920,000 chars = 1,920,000 bytes = 1,875KB = 1.8 MB • Hard disk holds 10 GB ... or about 6000 text books!

Page 5: Data Representation and Storagejupiter.plymouth.edu/~wjt/Foundations/Lectures/DataRepresentation-old.pdf30 1E US Unit Separator 31 1F 00011111 DEL Delete . Title: Data Representation.PDF

16. Graphics and Music … Codes are good for much of the work of computers ... except for two things • graphics • music

17. Graphic images

• CRT TRANS • Scan on monitor TRANS • RGB Guns and Shadow Mask TRANS • Memory stores a value for each RGB point in the Shadow Mask • Memory values are sent to appropriate electron gun which

creates the correct intensity of the electron beam 18. Representation of Colors TRANS

• Graphics ... bit maps • SVGA 800 X 600 ... 24 bits (224 colors) … 1.37 MB • floppy disk is 1.4 MB except that we use compression and

storage/compression techniques such as .jpg .gif .bmp .tif 19. Music … musical sound

• sampling and digitization • D -> A converters

20. Calculations ... codes are not good for addition and other arithmetic

operations. Therefore we transform numbers to a different format ... and it is the responsibility of the program to know what format to put things in!

21. Integer Addition of positive numbers

0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 10

reset the place and put one in the next level ... just like 9 + 1 = 10 0100 0111 1100 Never more complex ... because 0110 0111 0110 we never add more than two ------ ------ ------ numbers at a time ... explain 1010 1110 10010 adding a column.

William J Taffe
William J Taffe
William J Taffe
William J Taffe
Page 6: Data Representation and Storagejupiter.plymouth.edu/~wjt/Foundations/Lectures/DataRepresentation-old.pdf30 1E US Unit Separator 31 1F 00011111 DEL Delete . Title: Data Representation.PDF

22. Negative integers ... various methods to represent negative numbers

• Sign-magnitude • Two’s complement

23. Sign-magnitude representation … most significant bit represents the

sign ... the other bits represent the number • XYYY = X000 -> X111 => 0..7 • XYYYYYY = X0000000 -> X1111111 => 0 .. 127 • All computers have a largest number • Advantage ... it’s easy • Disadvantage ... arithmetic rules don’t work

24. To form two's complement

• Form number in binary • If it is negative • Take its complement • Add one • If the MSB is 1, the number is negative • Advantage ... arithmetic rules work • Disadvantage ... it’s a bit more complicated to understand • An example -4

25. Subtractrion of Integer numbers • Not necessary … form negative of second number and add!

26. Floating Point … real numbers … 2.37 or 5.6X104

• Leave to the course in Computer Hardware

Page 7: Data Representation and Storagejupiter.plymouth.edu/~wjt/Foundations/Lectures/DataRepresentation-old.pdf30 1E US Unit Separator 31 1F 00011111 DEL Delete . Title: Data Representation.PDF

Program Data

Computer

Output

Page 8: Data Representation and Storagejupiter.plymouth.edu/~wjt/Foundations/Lectures/DataRepresentation-old.pdf30 1E US Unit Separator 31 1F 00011111 DEL Delete . Title: Data Representation.PDF
Page 9: Data Representation and Storagejupiter.plymouth.edu/~wjt/Foundations/Lectures/DataRepresentation-old.pdf30 1E US Unit Separator 31 1F 00011111 DEL Delete . Title: Data Representation.PDF

Next TRANS

Page 10: Data Representation and Storagejupiter.plymouth.edu/~wjt/Foundations/Lectures/DataRepresentation-old.pdf30 1E US Unit Separator 31 1F 00011111 DEL Delete . Title: Data Representation.PDF

Decimal Hex Binary Char Symbol Meaning

0 0 00000000 NULL Null 1 1 00000001 SOH Start of Heading 2 2 00000010 STX Start of Text 3 3 Etc. ♥ ETX End of Text 4 4 ♦ EOT End of Transmission 5 5 ♣ ENQ Enquiry 6 6 ACK Acknowledge 7 7 • BEL Bell 8 8 Etc. BS Backspace 9 9 HT Horizontal Tab

10 A LF Line Feed 11 B VT Vertical Tab 12 C FF Form Feed 13 D CR Carriage Return 14 E SO Shift Out 15 F SI Shift In 16 10 DLE Data Link Escape 17 11 DC1 Device Control 1 18 12 DC2 Device Control 2 19 13 DC3 Device Control 3 20 14 DC4 Device Control 4 21 15 NAK Negative Acknowledge 22 16 SYN Synchronous Idle 23 17 ETB End of Transmission Block 24 18 CAN Cancel 25 19 EM End of Medium 26 1A ESC Escape 27 1B FS File Separator 28 1C GS Group Separator 29 1D RS Record Separator 30 1E US Unit Separator 31 1F 00011111 DEL Delete

Page 11: Data Representation and Storagejupiter.plymouth.edu/~wjt/Foundations/Lectures/DataRepresentation-old.pdf30 1E US Unit Separator 31 1F 00011111 DEL Delete . Title: Data Representation.PDF
Page 12: Data Representation and Storagejupiter.plymouth.edu/~wjt/Foundations/Lectures/DataRepresentation-old.pdf30 1E US Unit Separator 31 1F 00011111 DEL Delete . Title: Data Representation.PDF
Page 13: Data Representation and Storagejupiter.plymouth.edu/~wjt/Foundations/Lectures/DataRepresentation-old.pdf30 1E US Unit Separator 31 1F 00011111 DEL Delete . Title: Data Representation.PDF
Page 14: Data Representation and Storagejupiter.plymouth.edu/~wjt/Foundations/Lectures/DataRepresentation-old.pdf30 1E US Unit Separator 31 1F 00011111 DEL Delete . Title: Data Representation.PDF
Page 15: Data Representation and Storagejupiter.plymouth.edu/~wjt/Foundations/Lectures/DataRepresentation-old.pdf30 1E US Unit Separator 31 1F 00011111 DEL Delete . Title: Data Representation.PDF