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

Add Jump With Return instruction #2

Open
zHoeshin opened this issue Jan 28, 2024 · 3 comments
Open

Add Jump With Return instruction #2

zHoeshin opened this issue Jan 28, 2024 · 3 comments

Comments

@zHoeshin
Copy link

Basically adding support for calling functions.
Jump with return pushes the PC to the stack(whether accessible elsewhere or not) and jumps.
Return pops the value from the stack and jumps to this value.

@Macpunk
Copy link

Macpunk commented Jan 28, 2024

I hope I'm not mistaken, but I didn't see any hardware stack support in this ISA. You could use one of the GPRs to simulate a stack, however. But now we're talking ABI spec.

Without a TRAN PC, REG/TRAN REG, PC or JMP REG instruction, I can't see a trivial workaround to this issue.

I suppose you could theoretically implement a RET instruction as a JMP IMM, but before executing that instruction, modify the destination. You'd have a somewhat weird looking epilogue, because self-modifying code sucks, but it should work.

@sergiodavies
Copy link

Before thinking about a hardware support for the stack, I would implement a TRAN PC / REG and TRAN REG / PC. This would allow a software stack, with little changes to the current architecture. I think the multiplexer on the PC would need updating and accordingly there would be an instruction that could read from PC.

@perdo-nober-rs
Copy link

I think jump with call not good for excel cpu. excel cpu is already slow, should optimize running code by inlining function instead of having redundant call ret. like shader for gpu do.

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

4 participants