Skip to content

Use la/jr pseudoinstructions for main function call #297

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

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

Conversation

janderholm
Copy link

Replace direct jal with load address and jump register pseudoinstructions to support main functions located beyond the ±1MB range of direct jumps.

Together with a custom link script, this allows placing the bulk of the code in RAM which is likely located far away.

I use it for loading everything from a very slow SPI flash into SRAM on an FPGA. But it's useful for things like decreasing power consumption by powering off flash as well.

@janderholm janderholm requested a review from a team as a code owner June 11, 2025 19:06
romancardenas
romancardenas previously approved these changes Jun 13, 2025
Copy link
Contributor

@romancardenas romancardenas left a comment

Choose a reason for hiding this comment

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

LGTM! Maybe #153 can benefit from this PR.

@janderholm please add an entry into the CHANGELOG.md file

rmsyn
rmsyn previously approved these changes Jun 13, 2025
Copy link
Contributor

@rmsyn rmsyn left a comment

Choose a reason for hiding this comment

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

LGTM, too. Just out of curiosity, why is the separate quoting needed here (I see it was present before the changes, too)?

@romancardenas
Copy link
Contributor

LGTM, too. Just out of curiosity, why is the separate quoting needed here (I see it was present before the changes, too)?

The code for RV32 and RV64 differs, but the call to main is the same

@romancardenas
Copy link
Contributor

@janderholm can you add an entry to CHANGELOG.md so this PR can be merged?

Replace direct jal with load address and jump register pseudoinstructions
to support main functions located beyond the ±1MB range of direct jumps.
@janderholm janderholm dismissed stale reviews from rmsyn and romancardenas via d470afd June 16, 2025 16:31
@janderholm
Copy link
Author

Does this look alright?

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.

4 participants