There are probably a few open source emulators for various platforms out there if you'd like to take a look at the code see how they work.
Extremely high level answer, you have to take an architecture and duplicate it in software that can run on a different architecture. Generally it takes people experienced with fairly low-level system programming, from what I've seen.