I just take sequential screenshots myself, then assemble them in Fireworks. Certain emulators can simplify things. For instance, ZSNES can remove background layers and take frame-by-frame screenshots, both of which make the process much easier.
A simple search would have answered your question. There are plenty of programs that can produce animated gifs, some undoubtedly freeware, but I find Fireworks to be the easiest (for me). Not to mention its other uses.