Upload
emmeline-ross
View
216
Download
0
Embed Size (px)
Citation preview
off = 0
on = 1
O1 1 1 1O O O
O 11 1 OO 1 O
Bits and Bytes in a computers memory
Inside the computer are millions of electronic switches. These are grouped together in bundles of 8. A switch can be either on or off. It can be seen then that a switch can stand for either a 1 when it is switched on or a 0 when it is switched off.The switches are gathered into bundles of eight, and by having them on and off different patterns can be made, e.g.:
The system of numbers, which has only 0’s, and 1’s is called BINARY. Each 0 or 1 is a BInary digiT or BIT for short.
Basic Concepts
A computer’s most basic element is a switch, either off or on.
1 0 0 1 0 0 0 0
0 0 1 0 1 1 1 0
0 1 0 0 1 1 0 1
1 0 1 1 0 1 0 0
1 1 0 1 1 0 1 0
0 0 0 1 1 1 0 1
1 1 1 0 1 0 0 0
1 0 0 0 0 1 0 1
1 0 0 1 1 0 1 0
0 1 1 1 1 0 1 1
0 0 1 1 0 1 1 0
1 1 0 0 0 0 1 0
RAM or ROM: switches Written in a book – machine code
Why 8 bits = 1 Byte?
8 different switches can have 256 different combinations.
For example A given ASCII code 65 = 01000001
This is enough to cover: 26 Upper case letters
26 lower case letters
10 different digits 0,1,2,…,9
All the punctuation marks on the keyboard e.g. !,”,£, |, * , #, etc.
4 or 6 bits would not be enough to cover all possibilities.
There are still some code numbers left over using 8 bits; these are used in programming for special effects. They are called CONTROL CODES.
We are all familiar with our characters in British English, but different countries use different character sets. Even America has slightly different characters. Think about Russian or Turkish!
8 bits =1 byte1024 bytes =1 kilobyte ( 1 Kb)1024Kb =1 megabytes ( 1 Mb)1024 Mb =1 gigabyte( 1 Gb)1024 Gb =1 terrabyte
Someone has said that the storage of the human brain is just over 4 Terrabytes
Storage Capacity
This is how much data that RAM, ROM, disks etc. can hold
file saved at different parts ofthe disk
file saved at track 2sector 0
1
2
0
A disk is FORMATTED into tracks and sectors
This allows the FILE MANAGEMENT system to find files on disk
1
2
0
Tape storage
This uses SEQUENTIAL ACCESS i.e. the system has to read from beginning to end of the tape to find records or data.
It is therefore slow. You would not want to use it at your home computer! Why use it?
Robust
High Capacity
Cheap
Easily stored
Disk storage uses DIRECT ACCESS, because the disk read heads go directly to the start of the file to read the file.
It is sometimes also called RANDOM ACCESS
Record Record Record Record Record Record 1 2 3 4 5 6
MAGNETIC TAPE
Microscopic 'magnets' withdifferent polarity.The drive head can detect these - and eg no change = 0, change = 10 1 0
How does information get stored on these lines of "magnetism"? Look at the diagram:
All data is stored as binary numbers and the different polarities (i.e. north and south pole) lead to the binary digits being laid down on disk. As the read head passes over the microscopic magnets, a change in polarity is a ‘1’, and no change in polarity is a ‘0’.
Disk READ HEAD
Surface of the disk
Example. A book has 345 pages. Each page has an average of 82 lines, 9 words per line and 7 letters per word.
How many bytes are required to store the book ? How many kilobytes is this?
Solution: 1 letters takes 1 byte;
no. of letters = 345 X 82 X 9 X 7=1782270 letters=1782270 bytes to store the book
to change into kilobytes divide by 1024
= 1782270/1024 Kb = 1740.5 Kb
Membership number <---8---->
Surname <--------20 letters---> Middle Initials <--5-->
First Name <------18---------->Age <-3->
Address 1 <-----------25------------>
Address 2 <-----------25------------>
Address 3 <-----------25------------>
Data stored in a database
Look at this record:
Example. How much storage space would be required for 20,000 records like the one above?
Solution.There are eight fields in each of the records.
Field Name Data Type Field Size
Membership Number
Alphanumeric
8
Surname Text 20
Middle Initials
Text 5
First Name Text 18
Age Number 2 (numbers are always 2 in Access)
Address 1 Text 25
Address 2 Text 25
Address 3 Text 25
The number of characters for each record is 8+20+18+5+2+25+25+25 = 128Hence the total number of bytes required
= 128x20000 bytes= 2560000 bytes= 2560000/1024 Kb= 2500 k
The PC computer (and MacIntosh) computers use directories to organise their filing system.
File 1
Hard Disk
File 2
File 1 File 2
File 1 File 2 File 1
File 1
Folder 1 Folder 2 Folder 3
Folder 4 Folder 5
The situation can be represented in this diagram:
This is called a Hierarchical Filing system.
100 perform_preparations200 while item NOT found do300 begin400 if value <> search 500 then600 process700 else800 increment900 end if1000 end1100 end while1200 process_results1300 print_table1400 end
100101101010100001100001010010111110001100110010110100101001011110010010101000001010010000111110
╬nterpreting:1 one line at a time2 translates AND executes3 NO machine code version4 errors detected early
T ra
n
s lat i o
n
execute
get next line
Interpreter
Takes ONE line at a time
Translates it
Executes it
Gets next line
Pro Con
Interpreter As it executes lines of code after it translates, it finds errors quickly
It does not produce object codeAs it re-translates each line of code inside a loop for example, it can be slow
Compiler Produces fast object code
Difficult to find errors
Assemblers. Assembly language is a LLL that can be used reasonably easily by scientists but is near to machine code (the actual language of the processor).
10010110101010000110000101001011111000110011001011010010100101111001001010100000101001000011001110
T ra
n
s l a t i o
n
LDA &C3AAADC &FF00STA &C3ABTAYBNE &FF0AADC #&222
Assembly program
ASSEMBLY:
1 Used by experts to get memory efficient code
2 Translates directly
3 Gives fast machine code version
4 Similar to compiler
These are location ADDRESSES in a number system called HEX
These are codes for binary commands