An emulator reads the original machine code instructons that were assembled for the target machine, interprets them, and then replicates the functionality of the target machine on the host machine. The ROM files contain the instructions, the emulator reads those instructions, and then does work to mimic the original machine.
When an emulator reads the instruction $7522, it would emulate the behaviour of the CHIP-8 by doing something like this:
registerp[5] += 0x22That’s really all there is to it. When emulating more advanced machines you also have to emulate other components like the graphics processor and the sound chip. The CHIP-8 is a nice starting project because the CPU only has 34 instructions, the graphics are simple monochrome pixels, and the sound are just a single buzzer tone.