Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Closed
wants to merge 1 commit into 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?

wargio added a commit that referenced this pull request Sep 22, 2024
wargio added a commit that referenced this pull request Sep 22, 2024
wargio added a commit that referenced this pull request Sep 22, 2024
@wargio wargio closed this Sep 22, 2024
wargio added a commit that referenced this pull request Sep 22, 2024
* Fix infinite loop (issue #324)
* Simplify merge_arrays
* Fix adrp marker (issue: #327)
* Fix eslint-check.sh
* Add support for brab braa braaz brabz (issue #325)
* Add support for cinc (issue #326)
* Fix riscv lui (from PR #291)
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants