Isuranga Perera Isuranga Perera -4 years ago 125
C++ Question

For a trap in a C++ emulator, what should the CPU execute?

I’m writing a decode function for a C++ MIPS emulator I am making. What should my decode function send to my CPU::excute() function after the decode? What should I do with the pc?

Answer Source

A trap instruction typically invokes a trap handler, which is a piece of code it jumps to, usually based on an initial trap vector (just an address). From there the trap handler is up to you. A typical case would be to use the trap number to look up a routine in a table and jump to it, and so extend the effective instruction set of the CPU.

You’ll need to look up what the chip you’re trying to emulate does, and do the same thing, if you hope to have your emulator execute actual code written for the chip.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download