wpe41.gif (23084 bytes)CIS3355: Business Data Structures
Fall, 2008
 

How do we know where a piece of datum is stored in RAM?

What is Random Access Memory? Random Access Memory is used to temporarily store information that the computer is working with. It is the component in the computer where most programs are loaded. These programs in RAM perform their functions and operate to give the user the required results.

Most RAM memory is stored in chips (integrated circuits ICs) that are found on the motherboard of a computer. Memory chips are normally only available as part of a card called a module. Below are examples of a SIMM (single in-line memory module), a DIMM (dual in-line memory module), and a SODIMM (small outline dual in-line memory module) from left to right respectively.

 

                                      

 

                                          

 

 

 

 

When we reserve bits of storage for a given datum, for example in the following C Declarations:

 

         
 

Char a = ‘c’

 

 

 

Short b = 50

 

 

 

Int c = 5487

 

 

 

 

 

 

 

Remember, characters require 8-bits of storage (1-byte), shorts require 16-bits of storage (2-bytes), and integers/longs require 32-bits of storage (4-bytes).

1.                we know that we are reserving 7-bytes of storage – 1-byte for a, 2 contiguous bytes for b, and 4 contiguous bytes for c

2.                we are associating the locations with variable names (Location a,b,c)

3.                we are initializing location a with the character ‘c’ (ASCII = 99, 011000112), location b with the value 50 (00000000-001100102), and location c with  the value 5487 (00000000-00000000-00010101-011011112)

So the question is where in RAM will we find location a, b, and c?  Address allocations are made at RUN-TIME and are based on available locations.  At this point we don’t know where a, b, and c  are stored.  The table below is an illustration of where the above variables may be stored in RAM.

                                                                

For more detailed information on RAM allocation (references I used), here are a few sites to look at:

http://www.ece.utexas.edu/~valvano/embed/chap3/chap3.htm

http://www.allsands.com/Computers/whatisramrand_wde_gn.htm

http://www.howstuffworks.com/ram1.htm

Practice multiple choice and short answer questions:

1.     How many bytes/bits of storage would a data type float require?

a)                2 contiguous bytes

b)               4 contiguous bytes

c)                16 bits

d)               32 bits

e)                both a and c

f)                  both b and d

 

2.  How many contiguous bytes/bits of storage would a data type double require?

 

a)                64 bits

b)               16 bytes

c)                32 bits

d)               8 bytes

e)                a and d

f)                  none of the above

 

3.  How many contiguous bytes/bits of storage would a data type long double require?

 

a)                32 bytes

b)               32 bits

c)                128 bytes

d)               128 bits

e)                a and d

f)                  none of the above

 

4.  Given the following C code what would be the output? 

 

char age = 13, weight = ‘c’

printf(“The child is age %d and weighs %d lbs”, age, weight);

 

5.  In question 4, how many bytes of storage were reserved and if the specifier for age was

     %c what would be the outcome?

 

6. Name the conversion specifiers for printf that we used for Project 1 (there were 4).

 Answers:

 

1.                f.

2.                e.

3.                d.

4.                The child is age 13 and weighs 100 lbs

5.                2 bytes; 1 byte for age and 1 byte for weight – the outcome for age if %c was used would be the BS (backspace) ASCII 13

6.                %c, %d, %o, %x