******memory organization******

----------------------------------------------

Author: Ennis (see Note *)

E-mail: nho@hackermail.com

*Note

As you can see I can translated this tutorial from a book called Turbo Pascal: Programming and Problem Solving by Sanford Leestma and Larry Nyhoff.

I put it into my own words so that I would learn it easier you see! Hopefully it helps people here. The book is a lot more complicated than my version.

**note about the text**

contents

a. MEMORY ORGANIZATION

b. NUMBER SYSTEMS

c. DATA STORAGE

d. INSTRUCTION PROCESSING

*disclaimer*

The main purpose of this text is to give a clearer view of how computers work and any misuse of the information involved is in no way the responsibility of the author!

If you are a newbie you may find this text extremely useful, and all you l33t hax0rs could do a bit of revision now and again.

NB: 2^2 means 2 to the power of 2

eg 4^5 is 4 to the power of 5.

a. MEMORY ORGANIZATION

The devices that comprise the memory unit of a computer are two-state devices. If one of the states is interpreted as 0 and the other as 1 the it is natural to use a BINARY scheme, using only the two binary digits [BITS] 0 and 1 to represent info on a computer.

The two state devices are organized into groups called BYTES, each which contains a fixed number of these devices, usually 8, and thus can store a fixed number of bits.

Memory is commenly measured in bytes, and a block of 2^10 [in this text ^ will denote to the power of

eg. 2^10 is 2 to the power of 10].

So 2^10 = 1024 bytes is called 1K of memory.

Thus a 512K memory usually refers to a memory that consists of 512 x 2^10 = 2^9 x 2^10 = 2^19 = 524,288 BYTES.

A larger grouping of bits and bytes is into WORDS.

Each word is identified by an address and can be directly accessed with this address.

This makes it possible to store info in a specific memory location and then retrieve it later.

To understand how this is done we must first examine the binary number system.

b. NUMBER SYSTEMS

The number system we are accostumed to using is a decimal or base-10 system, which uses the digits,

0,1,2,3,4,5,6,7,8,9. The significance of these digits in a numeral depends on the positions that they occupy in that numeral

485

the digit 4 is interpreted as

4 hundreds

and the digit 8 as

8 tens

and the digit 5 as

5 ones

Thus the numeral 485 represents the number four-hundred eighty-five and can be written in expanded form as:

(4 x 100)+(8 x 10)+(5x1)

or

(4 x 10^2)+(8 x 10^1)+(5 x 10^0)

The digits that appear in the various positions of a decimal (base-10) numeral thus are coefficients of powers of 10.

Similar positional number systems can be devised using numbers other than 10 as a base. The binary number system uses 2 as the base and has only two digits, 0 and 1. As in a decimal system the significance of the bits in a binary numeral is determined by their positions in that numeral.

For example the binary numeral

101

can be written in expanded form as

(1 x 2^2)+(0 x 2^1)+(1 x 2^0)

that is the binary numeral 101 has the decimal value 4+0+1= 5

Similarly the binary numeral 111010 has the decimal value (1 x 2^5) + (1 x 2^4) + (1 x 2^3) + (0 x 2^2) + (1 x 2^1) + (0 x 2^0)

= 32+16+8+2

= 58

Decimal Binary

0 0

1 1

2 10

3 11

4 100

5 101

6 110

7 111

8 1000

9 1001

10 1010

11 1011

12 1100

13 1101

14 1110

15 1111

16 10000

17 10001

18 10010

19 10011

20 10100

21 10101

22 10110

23 10111

24 11000

25 11001

26 11010

27 11011

28 11100

29 11101

30 11110

31 11111

c. DATA STORAGE

INTEGERS- When an integer value must be stored in the computers memory, the binary representation of that value is typically stored in one memory word.

To illustrate consider a computer whose word size is 16 bits and suppose that the value 58 is to be stored.

A memory word is selected , and a sequence of sixteen bits formed from the binary representation 111010 of 58 is stored there:

MEMORY

_______________

|_______________|

|_______________|

0000000000111010

|________________|

|________________|

Negative integers must be stored in a binary form in which the sign of the integer is part of the representation. There are several ways this can be done. The most commen is the twos complement representation. In this scheme positive integers are represented in binary form as just described, with the leftmost bit set to 0 to indicate that the value is positive.

The representation of a negative integer -n is obtained by first finding the binary representation of n, complementing it, that is changing each 0 to 1 and each 1 to 0 and then adding 1 to the result.

EXAMPLE: -58

1-Represent 58 by a 16-bit binary numeral

0000000000111010

2-Complement this bit string

1111111111000101

3-Add 1

1111111111000110

Note that the leftmost bit in this twos complement representation of a negative integer is always 1, indicating that the number is negative.

The fixed word size limits the range of the integers that can be stored.

REAL NUMBERS- Numbers that contain decimal points are called real or floating point numbers.

The decimal numeral 56.317 can be written in expanded form as

(5 x 10^1)+(6 x 10^0)+(3 x 10^-1)+(1 x 10^-2)+(7 x 10^-3)

Digits in the binary representation of a real number are coefficients of powers of 2. Those to the left of the binary point are coefficients of nonnegative powers of two and those to the rught are coefficients of negative numbers of two.

d. INSTRUCTION PROCESSING

We have now seen how various types of data can be stored in a computers memory. Program instructions for processing data must also be stored in memory.

Programs fo early machines had to be written in machine language but later it became possible to write programs in assembly language, which uses mnemonics (names) in place of numeric opcodes and variable names in place of numeric addresses.

For example the preceding sequence of instructions might be written in assembly language as

1. LOAD A

2. MULT B

3. ADD C

4. STORE X

An assembler which is par of the system software, translates such assembly code into machine language.

Today compilers translate each statement into a sequence of basic machine (assembly) language instructions.