A sensitive nose

About the size of a microwave oven, SAM can be thought of as a sensitive robotic nose that can sniff out air and soil samples in order to identify composition. Its job is to look for the presence of organics present billions of years ago that are preserved in the rock record.
SAM instruments. Image: NASA
Notice the inlet tubes at the top. They can either “inhale” the atmosphere or accept solid samples delivered with the arm.
Closed vs. open (right) inlet where powdered rock and soil samples will be funneled. Image: NASA/JPL-Caltech/MSSS
In order to “sniff” the solids it heats up samples in a oven to release gasses. Here is a short video on the sample heating and delivery process:
After a sample is baked to release its gases, SAM's can “taste” it using three instruments:  a gas chromatograph, a quadupole mass spectrometer and a tunable laser spectrometer. This diagram shows the flow from sample processing through analysis using the instruments.
Processing and analysis pipeline. Notice it begins with air or rock sample. Imagee: NASA/GFSC
Let's summarize what happens after the sample is collected. It is a three step process.

Separate the molecules (gas chromatography)

The gas chromatograph (GC) can sort out all the different molecules in the sample, and tell how much of each kind there is. It accomplishes this by using a stream of helium gas to push the sample down a long, narrow tube (which is wound into a coil to save space).
Sample is heated and pushed through a long coil during which separation occurs. Image: NASA/GFSC
Gas from the sample first travels to the Gas Chromatograph (GC) instrument. The purpose of Helium is used because it is inert, meaning it won't react with and change any of the sample molecules. The inside of the tube is coated with a thin film. As molecules travel through the tube, they stick for a bit on the film, and the heavier the molecule, the longer it sticks. Thus, the lighter molecules emerge from the tube first, followed by the middleweight molecules, with the heaviest molecules last.

Identify the molecules (quadrupole mass spectrometer)

This is the Quadrupole Mass Spectrometer (QMS) fires high-speed electrons at the molecules, breaking them up into fragments and giving the molecules and their fragments an electric charge. Molecules and fragments of different mass are counted by a detector at different times to generate a mass spectrum, which is a pattern that uniquely identifies molecules. This short video covers the basics:

Fine tuning (tunable laser spectrometer)

The tunable laser spectrometer will measure the abundance of various isotopes of carbon, hydrogen, and oxygen in atmospheric gases such as methane, water vapor, and carbon dioxide. The TLS will help determine the origin of any Methane that is detected. Tunable semiconductor lasers produce a very specific wavelength of light tuned to a fundamental frequency of the target gas molecule in the near infrared band.
Laser light passed through sample and analyzed for absorption patterns. Image: NASA/GFSC
The light causes the molecule to vibrate and therefore, absorb energy. The absorption lines allow us to measure concentrations and isotope ratios of specific chemicals important to life: methane, carbon dioxide, and water vapor.
Absorption patterns for different molecules. Image: NASA/GFSC

Watch full press conference on SAM: