I have a personal interest in firearms, and how they work.
Most automatic firearms work as a gas operated weapon, or a blowback weapon.
Gas operated firearms work by using the unused energy from rounds fired by bringing the gas back to the bolt to cycle the next round.
A blowback system operates by using backwards project energy from the spent shell to push back the bolt, eject itself, and cycle the next round.
http://www.basspro.com/Guns/_/S-12400001000?ddnv=FlyOSH_Gun