-
Notifications
You must be signed in to change notification settings - Fork 1.6k
M68K: add displacement size fields to disassembler #2842
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
Conversation
Rot127
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only this nitpick. Otherwise lgtm.
|
@csoren How many changes have you still planned? |
|
The original 68000 has address modes with displacement such as $1234(a0) and $12(a0,d0.w). These are word and byte size displacements respectively. The 68020 introduced new address modes that added word and long displacements, and the syntax changed slightly to ($1234.w,a0) and ($12.b,a0,d0.w), since also ($12345678.l,a0) and ($1234.w,a0,d0.w) were possible. Currently the printer outputs everything as $xxxx(a0,d0.w), regardless of displacement size. I would like to introduce an option to support the "new" syntax, since the current behavior is not accurate and also not correct wrt the new address modes. Additionally, some assembly language programmers prefer the old style syntax for the "old" address modes, so ideally I would also like an option for that. Another possibility is simply to forego compatibility and change the existing printer to use the official, "new" syntax. |
I prefer the first solution. Adding an option to select the syntax. |
|
It would be ready sometime tomorrow, January 6. |
|
I have something that implements the official Motorola syntax. I would like to make it a separate PR once this one is approved, but I can also roll it into this one. I expect there will be a little back and forth until it is accepted, however. Let me know what you prefer. |
|
Better a new one I think. |
Your checklist for this pull request
Detailed description
In the 68K ISA, displacements can be encoded as bytes, words or longs depending on the address mode. When writing assembly code, programmers usually specify these explicitly instead of relying on the default word size. Disassemblers usually, if not always, append the size specifier to displacements.
The PR enables this functionality to be implemented, but doesn't update the built-in assembly printer. The reason for this is the way these addressing modes are currently printed - they do not follow the convention set by Motorola in the 68000 Programmer's Reference Manual. This convention will implemented as an option in a later PR. For now only the API change is implemented, as I consider these separate concerns.
Three size fields have been added - in_disp_size, out_disp_size and disp_size, which provide information about the encoded size of in_disp, out_disp and disp respectively.
Test plan
Tests of the new fields have been added to tests/details/m68k.yaml. The existing opcode stream already contains a sufficient selection of encodings.