The short answer here is yes. Boyle's law for ideal gasses is that for a fixed amount of a gas in a closed system at a constant temperature the pressure is inversely proportional to the volume. This means that as you increase the pressure of a gas you will decrease its volume and as you decrease the pressure of a gas you will increase it's volume. They key here for your question is that we are talking about a fixed amount of gas in a closed system. The number of molecules of the gas is fixed, or held constant. Whether you choose to measure that number of molecules in terms of moles or mass (grams) it makes no difference since the total number of gas particles is being held constant.