Musashi icon indicating copy to clipboard operation
Musashi copied to clipboard

Support building opcode jump tables on host

Open JCLemme opened this issue 4 years ago • 0 comments

Right now Musashi builds its opcode handler jump table in RAM, which runs faster (for some reason) but blocks it from running on little memory-constrained microcontrollers. This PR fixes that by allowing this table to be built on the host and stored as a constant in the final executable. Most of this work was done by Sprite_tm in 2018 - I just integrated his changes in with the build system.

If I did things right the current build process should be the same, so no one needs to update their makefiles or scripts or whatever. If you want to use constant jump tables, you can run make constant instead of make and it'll tell m68kmake to generate these tables ahead of time. This also has the effect of splitting up the opcode handler functions and the jump table - the handler functions get prototypes in m68kops.h and the functions themselves go in a new file m68kinst.c.

summary of changes

  • defined a new type, m68ki_instruction_jump_call, that replaces void pointers in the opcode handler jump table
  • modified m68k_in.c so it can generate both the normal dynamic jump tables and the jump table generator
  • added a flag to m68kmake - "--constant" - that generates the jump table generator
  • split opcode handler functions into their own file m68kinst.c and added prototypes to m68kops.h (when building constant tables)
  • added a constant target to the makefile that builds all of this automatically

JCLemme avatar Dec 16 '21 09:12 JCLemme