Atoms and molecules are pretty small (understatement!) and, as scientists are interested in being able to describe quantities of matter in terms of the mass and number of particles contained per unit mass, this poses a problem. Measuring the mass of individual atoms, we find that one hydrogen atom has a mass of about 1.66 x 10^{27}g This number is far too small to be useful and so it makes sense to deal with quantities of atoms which can be measured in the laboratory. 
Amedeo Avogadro 
Hydrogen is the smallest atom and it was originally used as the standard by which all the other atoms were compared. It was assigned a value of 1 unit and other atoms masses calculated compared to hydrogen atoms.
The ^{1}H isotope has a mass assigned a value of exactly 1 atomic mass unit. This was the original reference.
The ^{1}H isotope 
Nowadays the ^{12}C isotope is used as a reference for comparison of relative atomic masses. This isotope has the assigned mass of 12.00000, all other atoms are measured relative to ^{12}C.
The ^{12}C isotope 
Measured on this scale hydrogen atoms (on average) have a relative mass of 1.00797
Carbon atoms have a relative mass of 12.01111 on average. Although this seems strange at first sight, it is because carbon has several isotopes ^{12}C, ^{13}C, and ^{14}C and the relative mass of carbon is given as the weighted average of all of the isotopes in a naturally occuring sample. Clearly the average must be greater than 12.0000.
Most tables use the relative atomic masses rounded up to one or two decimal places.
Carbon atoms have a mass approximately 12 times that of a hydrogen atom, therefore they have a RELATIVE mass of 12 (there are no units as it is a comparison  see relative measures)
number of hydrogen atoms

number of carbon atoms

mass of hydrogen atoms

mass of carbon atoms

mass of carbon:mass of hydrogen ratio


1

1

1

12

1:12

2

2

2

24

1:12

10

10

10

120

1:12

20

20

20

240

1:12

50

50

50

600

1:12

Provided the number of carbon atoms is equal to the number of hydrogen atoms the mass of carbon is always 12 times the mass of hydrogen.
Clearly there will be a specific number of hydrogen atoms that when weighed have a mass of 1g and that the same number of carbon atoms MUST have a mass of 12g. This number, named after its discoverer is called:
Avogadro's constant = 6.02 x 10^{23} 
Avogadro's number or constant is the number to which the mass of an atom must be multiplied to give a mass in grams numerically equal to its relative atomic mass.
Example Hydrogen has a relative atomic mass of 1 therefore 6.02 x 10^{23} hydrogen atoms have a mass of 1g Carbon has a relative mass of 12 therefore 6.02 x 10^{23} carbon atoms have a mass of 12g Magnesium has a relative atomic mass of 24 therefore 6.02 x 10^{23} magnesium atoms have a mass of 24g 
This gives rise to two important definitions
 The amount of any substance containing an Avogadro number of particles of that substance is called a mole.
 1 mole of any substance has a mass equal to its relative mass expressed in grams
Example 1 mole of magnesium contains 6.02 x 10^{23} magnesium atoms 1 mole of magnesium has a mass of 24g 12g of magnesium is equivalent to 1/2 moles = 0.5 moles of magnesium 12g of magnesium contains 1/2 moles of magnesium atoms = 0.5 x 6.02 x 10^{23} = 3.01 x 10^{23} magnesium atoms 
The relationship between moles, mass and number of particles can be expressed by simple formulae: