Skip to content

Implement RSBS instruction#17

Merged
lmSeryi merged 5 commits into
masterfrom
feat/rsbs
Feb 2, 2026
Merged

Implement RSBS instruction#17
lmSeryi merged 5 commits into
masterfrom
feat/rsbs

Conversation

@begeistert

Copy link
Copy Markdown
Collaborator

Description

  • Implement RSBS (reverse subtract with flags) execution in ArithmeticOps, decoding rn/rd from 3-bit opcode fields, using SubWithFlags, writing result to rd and updating flags.
  • Add RSBS encoding support in InstructionEmitter and register RSBS in the InstructionDecoder rules so it is recognized.
  • Restore and add unit tests: InstructionTests restored for RSBS and new ArithmeticOps test verifying negating zero sets Z and C flags.
  • Add dotnet-tools.json to pin csharpier for consistent formatting and simplify InstructionDecoder declaration (public sealed unsafe), removing unused singleton/complex init scaffolding.
  • Non-functional cleanup: fix file formatting/trailing blank removal and minor license/usings tidy.

Type of change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 🧹 Refactoring (no functional changes, just code cleanup)

Checklist

  • 🧪 Tests passed locally (dotnet test)
  • ✅ Added new tests for this feature/fix
  • 📝 Documentation updated (if applicable)
  • 🚫 No "Magic Strings" or hardcoded values
  • 💾 Validated against the RP2040 Datasheet (if applicable)

Screenshots / Hex Dumps (Optional)

Implement Rsbs (reverse subtract with flags) handler for ARM Thumb
in ArithmeticOps.cs. Decode rn and rd from the 3-bit opcode fields,
read rn, perform subtraction of rn from immediate 0 using existing
SubWithFlags helper, and write result back to rd while updating CPU
flags. Mark method aggressive-inline for performance.

This enables correct execution of Rsbs opcodes on the RP2040 Cortex-M0+
emulation core and fixes missing behavior for instructions that rely on
reverse subtract semantics.
Add a dotnet-tools.json to pin csharpier 1.2.5 for consistent formatting
across the repo.

Refactor InstructionDecoder declaration to "public sealed unsafe and remove
unused singleton and complex initialization scaffolding. This change
simplifies the class header ordering and ensures proper unsafe modifier
placement without altering decoder logic. Also reformat surrounding code to
match the project's style expectations.
Remove an extra blank line introduced at top of
src/RP2040.Core/Cpu/Instructions/ArithmeticOps.cs and normalize file
whitespace. This reverts an unintended insertion of a stray newline
that affected file formatting and kept the rest of the file contents
unchanged.

This is purely a non-functional cleanup to keep repository style
consistent and avoid spurious whitespace diffs.
Implement Rsbs instruction encoding generation in InstructionEmiter,
including argument validation for register indices. Add the RSBS
opcode to the InstructionDecoder rules so the decoder recognizes the
instruction. Restore RSBS-related unit tests in InstructionDecoderTests
and add a new ArithmeticOps test that verifies negating zero sets Z and
C flags correctly. Also remove an unused using and add a missing
copyright line in LICENSE.

These changes enable correct assembly emission, decoding, and execution
testing of the RSBS (Negate) instruction.
@begeistert
begeistert requested a review from lmSeryi as a code owner February 2, 2026 08:29
@begeistert begeistert self-assigned this Feb 2, 2026
Remove Spanish comments and redundant notes, rename and tidy up fetch-cache
handling and fast-fetch path to improve readability and keep implementation
intent clear.

- Strip non-English comments and extraneous TODO-like lines to unify code  language and reduce.
- Keep fetch cache fields and update logic intact; remove commented notes and
  redundant explanatory headers.
- Preserve fast-guard/fallback behavior but simplify inline comments and
  ensure fetchPtr null check behavior remains explicit.
- Minor comment wording tweaks (Spanish -> English) and a small comment fix
  for exception cycle wording (cycles instead of ciclos).

No behavioral changes intended; changes are purely comment/annotation cleanup
and minor code comment clarifications to improve maintainability.
@begeistert begeistert changed the title feat/rsbs Implement RSBS instruction Feb 2, 2026
@PyMCU PyMCU deleted a comment from sonarqubecloud Bot Feb 2, 2026
@begeistert

Copy link
Copy Markdown
Collaborator Author

SonarQube is complaining about Test Coverage, it will be fixed after finishing the ISA implementation

@lmSeryi
lmSeryi merged commit fa242f4 into master Feb 2, 2026
1 of 2 checks passed
@begeistert
begeistert deleted the feat/rsbs branch February 2, 2026 08:47
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