-
Hello, I'm writing a generator that automatically generates a Capstone Framework disassembler from Sail. Right now the progress is promising! One thing that stumped me is how to automatically know whether a literal is really a literal number or a memory address. The disassembler has to associate each ast case with metadata such as "this instruction has 3 operands: 2 registers and a memory operand". Recognizing registers is easy enough because they have a dedicated Is this an impossible problem? Is it really trivial for the particular case of RISC-V (e.g. "only LOADs and STOREs use addresses, everyone else use bits as literals" or something close to this) ? Is there another, hopefully "official" and regularly-maintained source of machine-readable information about this that I can use as an additional source? All answers are welcome! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You mean you want to somehow distinguish between the
and
? Yeah I don't think that's possible from the Sail types. I'm not sure why you'd need that for a disassembler either? They're disassembled in the same way. Neither of those are a memory address anyway - the
I think this is probably true; at least I can't think of any counter-examples. If you wanted to get extremely fancy you could follow the flow of information in the |
Beta Was this translation helpful? Give feedback.
You mean you want to somehow distinguish between the
bits(12)
inand
?
Yeah I don't think that's possible from the Sail types. I'm not sure why you'd need that for a disassembler either? They're disassembled in the same way. Neither of those are a memory address anyway - the
STORE
immediate is an offset.I think this is probably true; at least I can't think of any counter-examples.
If you wanted to get extremely fancy you could follow the flow of information in the
execute
clause to s…