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

Disassembler does not correctly disassemble some RVC instructions #166

Closed
Tracked by #125
lcgamboa opened this issue Oct 30, 2021 · 6 comments
Closed
Tracked by #125

Disassembler does not correctly disassemble some RVC instructions #166

lcgamboa opened this issue Oct 30, 2021 · 6 comments
Assignees

Comments

@lcgamboa
Copy link
Collaborator

Some RVC instructions do not disassemble correctly: c.addi, c.lui, c.li, c.mv, c.srli and c.jal.
An example program below. The program works perfectly, the problem is only in the disassembly.

c.addi a0, 1
c.lui a1, 0x2000
c.li a2,3
c.mv a3,a1
c.srli a3,3
c.jal -10

diss
`

@mortbopet
Copy link
Owner

Working on it at the moment; there are indeed some issues in both how bitfields are compared together as well as how the instruction matcher generates its match tree. Interesting that this has been highlighted through the C extension but wasn't an issue in the other parts of the ISA!

@mortbopet mortbopet self-assigned this Oct 30, 2021
@lcgamboa
Copy link
Collaborator Author

I believe it is because for normal ISA the opcode is 7 bits and it is always set from bit 6 to 0, which is not the case for RVC.

mortbopet added a commit that referenced this issue Oct 30, 2021
We need to match on all provided op parts, even if there is no aliasing purely based on comparisons with the opcodes of other instructions.

It might be that different instructions alias across non-opcode fields such as immediates or registers. If the ISA is valid, matching on all opcode parts should yield the correct instruction.
@mortbopet
Copy link
Owner

Should hopefully be fixed in the above set of commits...

@lcgamboa
Copy link
Collaborator Author

With this example it worked, but loading the test/riscv-tests-c/rvc.s file Ripes freeze.

Starting Ripes with the program test/riscv-tests-c/rvc.s loaded, the following error is displayed:

Ripes: ../Ripes/src/assembler/program.cpp:44: void Ripes::DisassembledProgram::set(unsigned int, Ripes::VInt, const QString&): Assertiva “addressToDisresMap.count(address) == 0” falhou.
Abortado

@mortbopet
Copy link
Owner

yep, found that as well, and trying to fix it know... It's like playing whack-a-mole!

@lcgamboa
Copy link
Collaborator Author

Everything working, problem solved.

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

No branches or pull requests

2 participants