Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support building opcode jump tables on host #84

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

JCLemme
Copy link

@JCLemme JCLemme commented Dec 16, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant