Aspirin is the brand name for Salicylic acid. Its production on Mars would be part of a larger chemical production system, and it can be used as a model for the complexity of the chemical industry that would be required for a Mars Settlement. The chemical formula of Salicylic acid is C7H6O3.
Aspirin could be synthesized from simple precursor molecules using the following synthesis path:
Chemical synthesis of Salicylic acid
Main production path
Separation by distillation -> Toluene (C7H8)
Toluene + O2 in a cobalt catalyzed reaction -> Benzoic acid (C7H6O2)
Benzoic acid + molten Sodium benzoate(C6H5COONa) in a copper-catalyzed reaction -> Phenol (C6H5OH)
Phenol + Sodium hydroxide(NaOH) -> Sodium phenoxide (NaOC6H5)
Sodium phenoxide +CO2 at 100 atm and 115 °C in a method known as the Kolbe-Schmitt reaction -> sodium salicylate (C7H5NaO3)
Sodium salicylate + acidification with sulfuric acid ->
Sodium benzoate production
Benzoic acid(C7H6O2) + Sodium hydroxide (NaOH) -> sodium benzoate (C6H5COONa)
Sodium hydroxide production
Sodium hydroxide is also known as caustic soda.
Sodium hydroxide (NaOH) is produced by the electrolysis of sodium chloride(NaCl-table salt) using the Chloralkali process.
Alternate biological production
It may be more practical to produce aspirin from the bark of the willow tree, that contains the amino acid Phenylalanine. However, this requires the mastery of enzyme catalyzed processes.
Wikipedia article Salicylic acid