....how does it detect what f stop I am using, even though the lenses are manual?...
One might say the M8 (and the M9) has two exposure meters. One measures light through the lens, and that´s the one that actually determines exposure times in Auto, or generates the readouts in Manual.
The other, simplified one has its cell in the little round window just beside the Leica ´red dot´. It measures light falling directly on the front, and so has no idea of the f/stop set on the lens, but the coding on the lens (or the manual lens setting) tells it the maximum aperture (it also probably helps in setting auto white balance, but that´s another thing).
So, the difference in reading is assumed to depend on how much the lens is really stopped down, and thus the f/stop setting can be computed.
But, just as an old-fashioned MR meter with external cell is usually less accurate than a TTL meter (influenced by stray light outside the image field & c), this comparison doesn´t give exact results.
Edit: Dave beat me to it, just when I was writing....