How do you calculate the atomic mass of magnesium?

$m \left(M g\right) = 24.31 \text{amu}$
Of course you may have $M g$ react with an element with known atomic mass, e.g. oxygen, and then weigh the before and after situation. But that's been done long ago, by the people who gave us those tables.