Skip to content

Added the disass-style command to the debugger #2907

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

Closed

Conversation

qwetboy10
Copy link

The command will set the disassembler to either output decimal or hex representations of immediates. This is to make disassembly more clear so you don't have to convert values in a different tool. The command works on both ARM and sm83 code. This commit was originally made to solve #2553. Unfortunately that issue was actually invalid. However I already had the functionality of changing between decimal and hex for immediates implemented, so I added a command that would control it.

The command will set the disassembler to either output decimal or hex
representations of immediates. This is to make disassembly more clear so
you don't have to convert values in a different tool.
@endrift
Copy link
Member

endrift commented Apr 28, 2023

First off: your editor appears to use soft tabs. Please use hard tabs to avoid causing reindentation issues.

Second: please use disasm-style instead of disass-style.

Copy link
Member

@endrift endrift left a comment

Choose a reason for hiding this comment

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

Should be good to merge after fixing these 3 issues.

Copy link
Member

@endrift endrift left a comment

Choose a reason for hiding this comment

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

More nits, sorry.

} else {
written = snprintf(buffer, blen, "$%02X", op.immediate);
if(disassemblyStyle == DISASSEMBLY_STYLE_HEX) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if(disassemblyStyle == DISASSEMBLY_STYLE_HEX) {
if (disassemblyStyle == DISASSEMBLY_STYLE_HEX) {

@@ -45,6 +47,15 @@ static const char* _armConditions[] = {
"nv"
};

static int _decodeImmediate(int imm, enum mDisassemblyStyle disassemblyStyle, char* buffer, int blen) {
switch(disassemblyStyle) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
switch(disassemblyStyle) {
switch (disassemblyStyle) {

Also, I meant having both the default and explicit cases separately listed, but it should probably be done with an if/else like you have in the SM83 implementation.

if (disassemblyStyle == DISASSEMBLY_STYLE_HEX) {
written = snprintf(buffer, blen, "$%04X", pc + (int8_t) op.immediate);
} else {
written = snprintf(buffer, blen, "%05i", pc + (int8_t) op.immediate);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
written = snprintf(buffer, blen, "%05i", pc + (int8_t) op.immediate);
written = snprintf(buffer, blen, "%i", pc + (int8_t) op.immediate);

if(disassemblyStyle == DISASSEMBLY_STYLE_HEX) {
written = snprintf(buffer, blen, "$%02X", pc + (int8_t) op.immediate);
} else {
written = snprintf(buffer, blen, "%03i", pc + (int8_t) op.immediate);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
written = snprintf(buffer, blen, "%03i", pc + (int8_t) op.immediate);
written = snprintf(buffer, blen, "%i", pc + (int8_t) op.immediate);

@endrift
Copy link
Member

endrift commented Jun 5, 2023

Any updates on this PR?

@endrift endrift closed this Jun 27, 2023
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.

[Feature Request] Give the disassembler the option to output decimal values to hexadecimal values
2 participants