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

Can spike-dasm disassemble specified extensions through the --isa option? #1879

Closed
ha0lyu opened this issue Dec 17, 2024 · 8 comments · Fixed by #1881
Closed

Can spike-dasm disassemble specified extensions through the --isa option? #1879

ha0lyu opened this issue Dec 17, 2024 · 8 comments · Fixed by #1881

Comments

@ha0lyu
Copy link

ha0lyu commented Dec 17, 2024

When I run spike-dasm to disassemble instructions, it disassembled vector extension. When I specify the extensions, it ignored. It seems that this tool could disassemble any instruction.

image

I have read the code of spike-dasm.cc, it supports the DEFAULT_ISA, which is rv64imafdc_zicntr_zihpm. In the code, spike-dasm will parse isa option, but it fails to disassemble instructions of specified extensions. Is this normal?

version: latest(a2dcf1f), 1.1.1-dev

@aswaterman
Copy link
Collaborator

Yes, this is the intended behavior. We always try to disassemble an instruction even if it corresponds to an extension that isn't enabled.

For this program, the only purpose of the --isa argument is to disambiguate conflicting cases, where a given opcode corresponds to a different instruction depending on which extensions are enabled. For example:

$ echo "DASM(0xb842)"|spike-dasm --isa=rv64imac_zcmp_zcmt
cm.push {ra}, -16
$ echo "DASM(0xb842)"|spike-dasm --isa=rv64imafdc
c.fsdsp fa6, 48(sp)

@ha0lyu
Copy link
Author

ha0lyu commented Dec 18, 2024

Hi @aswaterman,
Thanks for your reply. I got it.
I have another question about specified extensions disassemble.

For this program, the only purpose of the --isa argument is to disambiguate conflicting cases

Now, I want to change the source code to disassemble specified extensions by the --isa argument or another argument. I have checked the code: disasm.cc and isa_parser.h. The constructor function of class disassembler_t calls add_instructions function firstly. The add_instructions adds instructions according to *isa, then it adds instructions of each isa->extension_enable. Actually, this tool can not disassemble all instructions, it only supports rv32 and rv64 instructions. Here is my question: how can I change the code to support specified XLEN and extensions, such as rv32imcb, rv64gc, rv32gc, etc.

I need a tool to disassemble instructions. Since Spike is considered the golden model, I believe the best approach is to modify spike-dasm. As someone who is highly knowledgeable about Spike, could you please provide me with some guidance?

@aswaterman
Copy link
Collaborator

I’m not sure I follow exactly what you’re trying to do. Could you give some user stories (really just examples of input, command-line options, and desired output) that would illustrate your goal?

@ha0lyu
Copy link
Author

ha0lyu commented Dec 18, 2024

For example, I run spike-dasm --isa=rv32i, spike-dasm will only disassemble rv32i instructions.

  1. Such as bits= 0x3256 # c.fldsp ft4, 368(sp), this is a C extension instruction, spike-dasm will not disassemble it.
  2. Such as bits = 0x0182b283 # ld t0, 24(t0), this is a RV64I instruction, spike-dasm will not disassemble it.

In another case, I run spike-dasm --isa=rv64g, it will disassemble RV32g instructions, but will not disassemble C extension instructions.
I am not sure am I understood, please let me know if you are confused. Thanks.

@aswaterman
Copy link
Collaborator

I think this should be straightforward. Let me try to prototype something.

@aswaterman
Copy link
Collaborator

See #1881

@ha0lyu
Copy link
Author

ha0lyu commented Dec 18, 2024

I have tested it, it works. Nice job!
Thank you very much!

@ha0lyu ha0lyu closed this as completed Dec 18, 2024
@aswaterman
Copy link
Collaborator

You're welcome!

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 a pull request may close this issue.

2 participants