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

Sign-extending load for byte and word data #38

Open
Zardoz89 opened this issue Jan 1, 2015 · 5 comments
Open

Sign-extending load for byte and word data #38

Zardoz89 opened this issue Jan 1, 2015 · 5 comments

Comments

@Zardoz89
Copy link
Member

Zardoz89 commented Jan 1, 2015

For C it would be handy to have sign-extending loads like lb/lh on MIPS and movsx on x86 (otherwise signed char and signed short are often unfairly penalized when loaded from memory)

  • By Alexey (SmallerC author)

I think that this instruction would be very useful on assembly, not only to make the life more easier to an compiler, if not to make the life easy to everyone.

The idea is add two new load instructions : LOADSB and LOADSW
This two instructions does the same that LOADB and LOADW, but extends the sign, filling the most significant bits of the register with 0 or 1 on function of the sign of the read byte/word.

@Zardoz89 Zardoz89 added the TR3200 label Jan 1, 2015
@Zardoz89 Zardoz89 changed the title TR3200 : sign-extending load for byte and word data Sign-extending load for byte and word data Jan 1, 2015
@milesrout
Copy link
Member

Seems reasonable as long as an eye is kept on how much complexity we introduce with changes that add new instructions and flags and generally things to remember.

@Zardoz89 Zardoz89 modified the milestone: v0.5.0 Mar 20, 2015
@milesrout
Copy link
Member

Actually I'm not sure why we need this. We have LOAD{W,B} and SIGX{W,B}. I'm not sure what benefit we get out of combining them. It adds unnecessary complexity to the implementation. The whole point of a RISC architecture is that we have a lot of orthogonal instructions: loads and sign-extension, not loads, sign-extension and sign-extending loads.

We could do this, I'm just not sure that we should.

@milesrout
Copy link
Member

I know that RISC doesn't mean "few instructions", but it does mean that memory access and data manipulation should be separated. I'm not sure if you think that we should consider sign-extension to be data manipulation, I think we should.

@Zardoz89
Copy link
Member Author

Taking a quick look, the SPARC (the most classic RISC CPU) have loads with sign extend. I don't think that should add extra complexity.

@milesrout
Copy link
Member

But why

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants