-
Notifications
You must be signed in to change notification settings - Fork 88
CPU Library
The CPU emulator was designed to be easily modular-izable. It's relatively easy to separate the CPU into its own separate shared library. Integrating that into your own programs is a different story, though.
I'm writing this page because I'm currently using the CPU library in another project and I'd like to detail the steps that were needed to get it to work.
You can easily compile the library by running the following command, which will produce the file libhalfix.so
.
node makefile.js libcpu --output libhalfix.so
I assume that you can easily do the same on Windows and convert it into a DLL file, but I haven't tested this.
The complete collection of functions that you can use is in include/cpu/libcpu.h
. Copy (or symbolically link) the file to wherever it needs to be.
Add -L. -l:./libhalfix.so
to your build fact. The ./libhalfix.so
part is critical, or else ld.so
can't find the file. This took me too long to find out.
Call libcpu_init
first.
Are instrumentation callbacks supported?
If you mean the instrumentation callbacks in src/cpu/instrument.h
, no. There is a way to reroute data that would otherwise go to (non-existent) devices to you own callbacks, however.