Block 3 - The heart of the computer

Part 1 - Data representation and storage

Objective 1 Distinguish between true and false statements concerning the terms which relate to Part 1 in the index for this block, or explain the terms in your own words.

Objective 2 Explain howdata is stored in a computer and distinguish between data that can/cannot be represented digitally without approximation.

SAQ1 Comment on the following statement : "Inside a computer, data is stored and manipulated as 0s and 1s.

The statement is not quite correct as it stands. Inside a computer, the electronic circuits represent data by different electrical states and it is these different binary states which are stored or manipulated. Human beings find it convenient to describe these binary states by using the digits 1 and 0.

SAQ3 Can each of the following be expressed without approximation ina digital representation? If so, how many distinct values will need to be represented?

(a) The position of a light switch Yes - two values need to be represented, on and off.

(b) The positions of three light switches in a row Yes - eight values need to be represented, because there are eight possible combinations of on and off for the three switches.

(c) The speed indication on a speedometer which uses a scale and pointer No - there will always be some approximation when speed is quantized.

(d) The size of an egg The size cannot be represented digitally without some approximation.

Objective 3 Calculate how many different values can be stored in a computer word of a given length.

SAQ2 How many different patterns of 1s and 0s can be represented by:

(a) a 4-bit word 2 to the power 4 = 16 different patterns

(b) a 16-bit word 2 to the power 16 = 65 356 different patterns

SAQ11 How many different unsigned integers can be represented by a 16-bit word? 65 356 different integers

Objective 4 Use the positional notation for numbers.

SAQ4 In the denary number 10 726

(a) What are the weightings of the 7, the 0 and the 1? tens, thousands and ten thousands

(b) What is the most significant digit? 1

SAQ7 a) What binary number follows i) 11111 ii) 10111

i) 100000 ii) 11000

b) What binary number precedes 1000 0000?

0111 1111

Objective 5 Convert binary numbers to denary and vice versa; convert hexadecimal numbers to denary and vice versa; convert binary numbers to hexadecimal and vice versa.

SAQ5 How is the 4-bit binary number 101 interpreted? To what denary number is it equal? What is its most-signifcant bit?

1010 is interpreted as 1 two and 1 8. 8 + 2 = 10.

SAQ6 a) To what denary number is 1100 0110 equal?

It is equal to 128+64+4+2 = 198 in denary

b) In a 16-bit word, what is the weighting of the most-significant bit? Two to the power of 15 = 32 768

c) To what denary number is 1000 0000 0000 0001 equal? It is equal to 32 768 + 1 = 32 769

SAQ8 a) Convert the following to 4-bit numbers: i) 7 ii) 11

i) 0111 ii) 1011

b) Convert denary 130 into an 8-bit binary number

0111 1000

SAQ9 a) Write down the binary numbers corresponding to i) F1 ii) A9 iii) 12 iv) 29BC

i) 1111 0001 ii) 1010 1001 iii) 0001 0010 iv) 0010 1001 1011 1100

b) Write down the hex numbers corresponding to the following binary numbers i) 1101 ii) 1110 1110 iii) 1011 0000 1111 0010

i) D ii) EE iii) B0F2

c) Write down the hex number that is one more than i) 2A ii) F iii) 39 iv) FF

i) 2B ii) 10 iii) 3A iv) 100

d) Write the following ten hex numbers in ascending numerical order:

BE 9F 100 FF 10 CA F EF CA E8

F 10 9F BE CA CD E8 EF FF 100

SAQ10 a) Convert the following hex numbers to denary: i) DF ii) 1B0A

i) D is 13 in denary and F is 15, so the number is (13 x 16) + (15 x 1) = 223

ii) B is 11 in denary and A is 10, so the number is (1 x 4096) + (11 x 256) + (0 x 16) + (10 x 1) = 6922

b) Convert the following denary numbers to hex i) 65 ii) 298

i) 41 ii) 12A

Objective 6 Convert from 8-bit 2's complement integers to sign-and-magnitude denary and vice versa; state the principles of converting from 16-bit 2's complement integers to sign-and-magnitude denary and vice versa.

SAQ12 a) In 2's complement representation, what denary number is equivalent to i) 1011 0111 ii) 0101 1011

i) -128+ 32 + 16 + 4 + 2 + 1 = -7 in denary

ii) 64 + 16 + 8 + 2 + 1 = 91 in denary

b) What is the 8-bit 2's complement equivalent of the denary numbers i) 25 ii) 96 iii) -2

i) 25 is postive so the msb is 0 and therefore the number is 0001 1001

ii) -96 is negative so the msb is 1 and therefore the number is 1010 0000

iii) -2 is -128 + 126. The sign bit is 1 and therefore the number is 1111 1110.

Objective 7 Explain how multiple-length integers, fixed-point fractions and floating-point fractions can be represented in a computer.

Large numbers can be held in two or more data words (double- or multiple-length notation).

When the binary point in a fraction is deemed to lie at a particular point in the data word the representation is called fixed-point. The alternative representation is floating-point, where the fractionis represented as a mantissa and an exponent and its value is (mantissa x 2 to the power exponent)

SAQ13 What is the range of numbers that can be represented in 2's complement double-length form in a computer with 16-bit word length?

32 bits are available, so 2 to the power 32 numbers can be represented. These are -2 147 483 648 to +2 147 483 647

SAQ17 How is the binary word 1100 0000 0010 0000 0000 0000 0000 0000 0000 interpreted?

The exponent bits are 1000 0000 which is 2 to the power 1. The significand is 1.010 0000 0000 0000 0000 0000 which is 1 + 0.25.

So the number is -1.25 x 2 to the power 1 = -2.5

Objective 8 Explain how text, Boolean data, pictures and sound can be represented in a computer.

Text is generally represented in computers as ASCII code. Boolean data can be represented either as a string of words each of which represents the state of one Boolean variable, or as one 8-nit Boolena word where each bit represents the status of one variable.

SAQ14 Write a sequence of binary codes which forms an answer to the following question:

1001001; 1110011; 0100000; 0110010; 0111101; 0110011; 0100000; 0111111

The question is: Is 2 = 3? So the answer is 'No.'

SAQ15 At one time only, switches B C and D are on. How would this be represented if:

a) one 8-bit word holds all 8 Boolean variables 0111 0000

b) instead, one 8-bit word holds one Boolean variable

0000 0000; 0000 0001; 0000 0001; 0000 0001; 0000 0000; 0000 0000; 0000 0000

Objective 9 Explain how the C data types int, short, long, unsigned int, unsigned short, unsigned long, float, double, long double, char can be represented for 16-bit computers; suggest a suitable data type for a particular variable.

SAQ16 In a particular C program for a 16-bit computer three denary integers will be multilplied together. Each of these integers can have values in the range -100 to +100. What data type should be used for the product? What do you think would happen of the data type int is used and why?

The largest positive value that can occur is 100 x 100 x 100 = 1 000 000 which is well outside the data range for int but inside the range for lond.

if the data type int were used, then the system would take the least significant 16 bits and interpret them as a 2's complement integer.

Objective 10 Explain how temperature measurements from the course's temperature-measuring system are represented in the computer.

SAQ17 How is the binary word 1100 0000 0010 0000 0000 0000 0000 0000 0000 interpreted?

Objective 11 Explain the use of memory addresses to identify locations in main memory and state what needs to be transferred between the processor and main memory during read and write operations.

Main memory is divided into a set of locations each of which can hold one data word and each of which has a unique address associated with it. The address of the location to be read or written from is sent to the memory by the processor on a set of conducting paths called the address bus and the data is transferred between memory and processor on another set of conducting paths called the data bus.

Objective 12 Interpret a memory map.

A memory map of the main memory of a pre-Windows IBM PC-compatible computer with a 20-bit address length shows that there was a mixture of ROM and RAM, with considerably more of the latter. Windows-based computers still retain this model for the first 1Mb of memory.

K stands for 2 to the 10 = 1024

M stands for 2 to the 20 = 1 048 576

G stands for 2 to the 30 = 1 073 741 824

Objective 13 Determine whether RAM or ROM is more suitable for data and/or program storage in a particular application.

SAQ18 For which of the following would ROM be more appropriate, and for which would RAM bemore appropraite? Give reasons for your choice.

a) To hold the data supplied by the temperature probe of your temperature-measuring system RAM - it is necessary to write the data into the memory as it comes in from the sensor

b) To hold a look-up table for the moves that can be made by each chesspiece in a computer chess game ROM - the data is unchanging and needs to be present automatically whenever the computer is used.

c) To hold the user's choice of on and off times in a micro-processor based central-heating system RAM - the user must be used so that the user can change the time settings.

d) To hold the computer instructions which are needed when a microprocessor-based computer is first switched on in order to prepare the machine for inputs from the user ROM - so that they are available to the processor as soon as the computer is powered on.