68000: movem.w should use 2 increments (not 4) #8824
+16
−16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On 68000, the movem instruction is the primary way to save registers on the stack. It comes in word (size 2) and long (size 4) flavors.
This patch corrects the modeling of the word variant of movem.
Per 68000 manual, when in word mode, increment (respectively decrement) is 2, and 4 in long mode. For word mode, the various registers masks are handled by m2rfw0, r2mbw0, and r2mfw0.
This patch corrects the pointer increment for r2mbw0 to 2 from 4, making it consistent with m2rfw0 and r2mfw0 (both correctly using 2 increments).
This corrects analysis of code blocks bookended by movem.w's. Before I would have the stack depth move from 0 to 4 then to 2; now it moves from 0 to 2 and back to 0.
(Edited 24th Dec '25 - post correction stack depth is zero as expected)