How Do Computers Store Information? by Duane Bristow The Helping Hand BBS (606) 387-4002 The power of a computer is derived from its speed, its ability to manipulate information, and its ability to store large amounts of information. This information is stored in the working memory of the computer in the state of electrical switches and in external memory as magnetic images. In either case information is stored by the fact that a given electrical switch can be in either of two states or a given area of storage can be magnetized or not. Think of storing information by a long series of switches each of which can be on or off or each of which can represent the number zero, off, or one, on. Now if you have perhaps 800 million switches, how can you store information? It was decided that information could be stored by means of using 8 switches at a time. A particular sequence of 8 switches would be called a byte. One individual switch would be a bit. A word would be 16 or 32 bits depending on the computer and its capability for handling information. If the fundamental unit of storage is to be 8 bits then it is possible to store 256 different combinations of off and on conditions in a byte. Each bit can be in either of two conditions, and 2 multiplied by itself 8 times gives 256. Some examples are: Base 2 Base 10 Base 16 Binary Decimal Hexidecimal 0000 0000 - 0 00 0000 0001 - 1 2^0 01 0000 0010 - 2 2^1 02 0000 0011 - 3 03 0000 0100 - 4 2^2 04 0000 1000 - 8 2^3 08 0000 1111 - 15 0F 0001 0000 - 16 2^4 10 0010 0000 - 32 2^5 20 0011 1111 - 63 3F 0100 0000 - 64 2^6 40 1000 0000 - 128 2^7 80 1111 1111 - 255 FF So we have a method for storing the integers 0 thru 255 in a single byte. We can now set up coding systems which can be interpreted by the program or set of instructions in our computer to store different types of information. One of the most widely used coding systems is ASCII. That stands for American Standard Code for Information Interchange and is used for storing mostly alphanumeric information in text format. In this system each alphanumeric and punctuation key on the standard keyboard is assigned a code number from 32 to 127. The space bar is 32, the exclamation point is 33, quotation marks are 34 etc. The capital A is 65 and the lower case z is 122. The numbers from 0 to 31 are called control characters and are used to send control codes to printers and other output devices. For example control code 12 tells the printer to feed to the top of the next page. 10 is a line feed. 13 is a carriage return. 8 is a backspace. 9 is a tab character. 7 rings the printer's bell. 0 is a null or nonprinting character. 26 is a character signifying the end of a file of text characters. The codes from 128 to 255 were left to be defined by each computer manufacturer and are called extended codes. Following are the codes for an IBM PC compatible computer: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33! 34" 35# 36$ 37% 38& 39' 40( 41) 42* 43+ 44, 45- 46. 47/ 480 491 502 513 524 535 546 557 568 579 58: 59; 60< 61= 62> 63? 64@ 65A 66B 67C 68D 69E 70F 71G 72H 73I 74J 75K 76L 77M 78N 79O 80P 81Q 82R 83S 84T 85U 86V 87W 88X 89Y 90Z 91[ 92\ 93] 94^ 95_ 96` 97a 98b 99c 100d 101e 102f 103g 104h 105i 106j 107k 108l 109m 110n 111o 112p 113q 114r 115s 116t 117u 118v 119w 120x 121y 122z 123{ 124| 125} 126~ 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 If numbers are to be stored, an integer less than 256 can be stored in one byte. 256 times 256 or numbers up to 65535 can be stored in two bytes. If it is necessary that the integers to be stored have a positive or negative sign then numbers from -32767 to +32767 can be stored in two bytes. It is also possible to store floating decimal point numbers accurate to seven significant digits in four bytes and floating decimal point numbers accurate to sixteen significant digits in eight bytes. If a picture consists of 320 pixels (dots) in width by 200 pixels deep (a common resolution) and up to 256 colors are defined for the picture then one pixel can be stored per byte and the entire picture can be stored in 320 X 200 or 64,000 bytes. It would be up to the application program of course to instruct the computer to place these pixels on the monitor screen in the proper colors to recreate the picture. Sounds can be stored in terms of the sound frequencies and durations of sound required to recreate a given sound and proper programs can output signals through a digital to analog converter, an amplifier and a speaker system to recreate sounds. So it is possible to store large amounts of a variety of different kinds of information in a computer system. Of course it is necessary to have application programs to interpret and manipulate this data as well as to accept it from input devices and send it to output devices. The information stored in a computer, besides the data types described above, can also be a program or set of instructions to the computer. A program would be interpreted by the ALU of the computer. More on this later. Both data and programs must be stored in a disk file or external long term storage when not in use. This is done by storing a series of magnetic impulses to represent the data. Special programs called the DOS or disk operating system enable the computer to carry out the functions of storing and reading these files. Typically a hard disk drive is capable of storing 32 million bytes. The information on this drive is stored in areas called files and identified by name. For instance the files on a disk drive might be as follows: Volume in drive D is DISK1_VOL2 <-- device identification Directory of D:\REC\GAMES\HANGMAN <-- sub directory . 7-18-90 8:53p .. 7-18-90 8:53p <-- pointer to parent directory HANGBAS1 WRD 12544 11-26-83 11:51a <-- HANGED1 WRD 28928 11-26-83 12:02p <-- data files HANGADV1 WRD 19456 11-26-83 12:03p <-- HANGMAN EXE 43052 3-23-84 1:20p <-- program file 6 File(s) 1474560 bytes free <-- amount of unused space on drive | | | | | FILENAME EXT SIZE DATE AND TIME LAST MODIFIED Each file name can be up to 8 alphanumeric characters long with up to 3 alphanumeric characters as an extension. Program files usually have an extension of COM, EXE, or BAT. For example the file HANGMAN.EXE above is a program file which, when loaded into the computer, will enable the computer to read the data files which have the WRD extension and contain words and play the game HANGMAN with the computer operator. The areas on a disk drive are subdivided into subdirectories and then subdivided again. In the example above the directory of files listed is a third level subdirectory. The directory structure of the drive might look like this: REC MOVIES TMC ART NIMBUS VGACRD FRACT GAMES CARDS HANGMAN <--- above example KEEN MUSIC EDUC JEOPARDY PCUSA POOTERS SIERRA TEXT ENCYCLOP ATLAS TIMEMAG Storage devices such as disk drives are usually labeled A through Z, with A and B denoting floppy disk drives and C through Z denoting hard disk drives although some of these may be physically located on other computers and accessed through a computer network system. Files may be accessed by the computer either sequentially or randomly. Program files are usually loaded into the computer's RAM memory sequentially in their entirety. Text files are often read in sequentially one line at a time. These files usually have variable length records with a combination ASCII code 10 and 13 designating the end of the line and a code 26 designating the end of the file. Random access files have records of fixed length. For instance suppose a file called MEMBERS.DAT is created to contain the list of members of the Saturday Afternoon Reader's Club. It might have a fixed record length of 100 bytes meaning that the first 100 bytes in the file contains the record for member number 1, etc. The file structure might be as follows. Each line in this record description is called a field. MEMBERS.DAT offset length type description field # 1 30 ASCII Member's name 1 31 30 ASCII Address line 1 2 61 18 ASCII City 3 79 2 ASCII State 2 letter code 4 81 12 ASCII Zip code 5 93 1 INTEGER Year of member's birth 6 94 1 INTEGER Month of member's birth 7 95 1 INTEGER Day of member's birth 8 96 5 INTEGER zero filled - unused. 9 Thus if Mary Brown is member number 5 and it is desired to find her birth month, the computer would simply read 100 bytes from the file MEMBERS.DAT starting at byte number 401. When this record had been loaded into memory it would only be necessary to read the byte at offset 94 to get Mary's birth month.