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

Feature/functional opcodes #11

Merged
merged 49 commits into from
Sep 19, 2018
Merged

Feature/functional opcodes #11

merged 49 commits into from
Sep 19, 2018

Conversation

rossdrew
Copy link
Owner

@rossdrew rossdrew commented Sep 19, 2018

Been looking at getting rid of the huge switch statement and mass of partner methods in the 6502. Largely this method has solved that problem and broken it down. This doesn't work so well for JMP commands but cleans the code up and makes it much more flexible.

This ends up saving about 200 loc and adding to the readability and composability. Also flagged up a few issues with my first implementation so it was a good exercise.

opposed to them just being data that the CPU acts on the existence of.
It get's rid of the huge case statement but doesn't really simplify
anything but it's worth the excercise.
This idea splits opcodes into three levels:
  - the operation (e.g. ASL) which includes everything needing done to
    execute an operation
  - the addressing mode (ACCUMULATOR), including getting an setting
    values from an addressed location
  - the combination of both to allow us to say things like ASL_A.execute()
OpCode already knows what it's AddressingMode and Operation are, so
explicitly stating them in a passed in function for each was overkill.
All I needed to do was call whatever AddressingMode and Operation was
part of that OpCode.  This is the same for all OpCodes so one method
for all replaces one for each.
They were in the wrong order
Including the addressing modes needed by LDX.
 - Immediate
 - Zero Page Y
 - Absolute Y
Also : Enabled BIT tests that I forgot to enable
 - Renamed operation to have 6502 prefix
 - Renamed addressing mode to have 6502 prefix
Could do with tidying up the stack logic
operation Javadoc

Now that all opcodes than can be enum-ed, have been, we can get rid of
the specific cases and apply the default to all but the exceptions.
Would still be nice to come up with a JMP strategy that allows us to
get rid of the case entirely but for now, it's much neater.
- More appropriate access modifiers
- map.putAll replaced with initialisation
- Collapsing exception catches that are identical
- Needless functional interface method reference
- Unused imports
- Improved Javadoc
@codecov-io
Copy link

codecov-io commented Sep 19, 2018

Codecov Report

Merging #11 into master will decrease coverage by 0.99%.
The diff coverage is 97.51%.

Impacted file tree graph

@@            Coverage Diff             @@
##             master      #11    +/-   ##
==========================================
- Coverage     98.54%   97.54%    -1%     
+ Complexity      516      413   -103     
==========================================
  Files            24       25     +1     
  Lines          1304     1305     +1     
  Branches         97       91     -6     
==========================================
- Hits           1285     1273    -12     
- Misses           10       20    +10     
- Partials          9       12     +3
Impacted Files Coverage Δ Complexity Δ
...java/com/rox/emu/processor/mos6502/Mos6502Alu.java 100% <ø> (ø) 15 <0> (ø) ⬇️
...mu/processor/mos6502/op/Mos6502AddressingMode.java 100% <100%> (ø) 26 <26> (?)
...emu/processor/mos6502/op/util/OpCodeConverter.java 100% <100%> (ø) 14 <1> (ø) ⬇️
src/main/java/com/rox/emu/env/RoxByte.java 100% <100%> (ø) 35 <2> (+1) ⬆️
...ox/emu/processor/mos6502/util/Mos6502Compiler.java 98.75% <100%> (ø) 33 <0> (ø) ⬇️
.../java/com/rox/emu/processor/mos6502/Registers.java 96.9% <100%> (-3.1%) 21 <3> (+2)
...va/com/rox/emu/processor/mos6502/util/Program.java 82.05% <100%> (ø) 26 <0> (ø) ⬇️
.../java/com/rox/emu/processor/mos6502/op/OpCode.java 100% <100%> (ø) 20 <2> (+1) ⬆️
...c/main/java/com/rox/emu/mem/MultiSourceMemory.java 100% <100%> (ø) 25 <1> (ø) ⬇️
...in/java/com/rox/emu/processor/mos6502/Mos6502.java 88.15% <70%> (-11.42%) 19 <6> (-191)
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f43d05d...6c5e141. Read the comment docs.

@rossdrew
Copy link
Owner Author

Next step should be to fix the test coverage

@rossdrew rossdrew merged commit 0b1d267 into master Sep 19, 2018
@rossdrew rossdrew deleted the feature/functional-opcodes branch September 19, 2018 17:17
@rossdrew
Copy link
Owner Author

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.

2 participants