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

RISCV: lui: properly sign extend on rv64 and rv32 #291

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

strlcat
Copy link
Contributor

@strlcat strlcat commented Jun 27, 2023

Quick but working fix. Tested both rv32 and rv64 (on rv32 simply ignored).
Feel free to edit to match your code (I'm noob at js)

Comment on lines +193 to +196
var imm = parseInt(instr.parsed.opd[1]);
var imm20 = imm << 12;
var n = new Long(imm20, ((Global.evars.archbits > 32) && imm & 0x80000) ? -1 : 0, true);
return Base.assign(dst, '0x' + n.toString(16)) ;
Copy link
Owner

Choose a reason for hiding this comment

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

Are you trying to sign-extend?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Forgive naive code. With current HEAD I get:

    lui a4, 0xff880                   |     a4 = 0xffffffffffffffff;
    addi a4, a4, -1

which is kinda annoying. I tried to fix it by various C-like means, but I always got 0 at imm20 stage, so I had to resort to throwing new Long object to make it simply work.

@trufae
Copy link
Contributor

trufae commented Jun 6, 2024

any update here?

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.

None yet

3 participants