The approach as far as I know is to multiply the molecular mass for O2, 32, by the molar mass constant 1g/mol. This gives a molar mass for O2 of 32g/mol. Dividing the mass of the oxygen gas by its molar mass yields the number of moles, i.e. 100/32 moles = 3.125 moles.
What has confused me was the use of a dimensionless quantity for the molecular mass. This confused me because I expected a unit of mass.
Another confusing point is that the molar mass is not a mass, as the name suggests, but actually has units of mass/mole.
As I understand it now, the following definitions explain the conversion procedure as used in the above.
Definition 1: the molar mass of 12C := 12 g/mole.
Definition 2: the molecular mass of 12C := 12u.
Replacing the unit u by the units g/mole turns the molecular mass of 12C into its molar mass. Equivalently, if its molecular mass is given without the unit u, then one simply multiples by 1g/mole (called the molar mass constant). The same conversion procedure holds for other molecules.
I have further confidence in my current understanding because the above definitions combine to produce the correct value for u. Only one further definition is needed to demonstrate this:
Definition 3: there are N_A particles in a mole.
It then follows that: 12u x N_A/mole = 12 g/mole.
Hence: u = 1g/N_A. If one takes the known value for N_A this indeed gives u = 1.66E-24 g.
Thank you both. I feel that you've helped me navigate a part of physics which, for me at least, is unnecessarily confusing because of its terminology and units.