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

Added display of immediate operands to disassembly #8

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

Conversation

weijuwang
Copy link

This is for issue #5. I replaced all the placeholders in the disassembly table with either %hhu for 8-bit immediates or %hu for 16-bit immediates. These are formats that printf understands. When disassembling an instruction, the code then looks for these substrings in the instruction's assembly representation and, if needed, passes the value of the immediate from memory as an argument to printf so that it can be displayed.

The debug output's disassembly now displays immediate values passed to instructions, when applicable.
@@ -4,6 +4,7 @@
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strstr()

@superzazu
Copy link
Owner

Hello, thank you for the contribution!

Can you use %02X and %04X instead of %hu and % hhu? It would be more consistent with the rest of the project, and more useful (I think?) to display those values as hexadecimal.

%hu -> %02X, %hhu -> %04X
Since immediates are being displayed in hex, an H is also added to the end of the value.
@weijuwang
Copy link
Author

Should be fixed now.

@weijuwang
Copy link
Author

weijuwang commented Jul 27, 2022

On a somewhat related note: the disassembly could be made more readable if some more spaces were added, e.g.

... cpo 06A0H
... cm  06A0H
... cnz 06A0H
... cpi 00H

as opposed to

... cpo 06A0H
... cm 06A0H
... cnz 06A0H
... cpi 00H

I could make a separate PR if needed, since it's not strictly related to immediate operands.

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