Comments (3)
After digging a bit more, I'm not quite sure how to proceed with this one. In our chat discussion, the examples given for this use case were the common lui
+ addi
combo for loading 32-bit immediate values. Due to the nuances of how RISC-V handles sign extension, I had to introduce a couple modifiers into the syntax in order to make this "work".
For example, it is always recommended (and usually necessary) to utilize the %hi
and %lo
modifiers when loading 32-bit immediates. They do no harm to values where the signedness causes no issue, but they "fix" values that would end up incorrect due to the sign-extension behavior of addi
.
ADDR = 0xffffffff
lui t0, %hi(ADDR)
addi t0, t0, %lo(ADDR)
An even simpler solution, however, would be to use the li
pseudo-instruction. It automatically handles the insertion of proper hi/lo modifiers.
ADDR = 0xffffffff
li t0, ADDR
Are there other use cases outside of this that I'm missing? I'm trying to get a better understanding of the behavior folks will expect as they find this assembler and start tinkering.
from bronzebeard.
After discussing this a bit more offline, it isn't a "showstopper". If signed operands accepted values outside of their "documented" range, would devs get confused? Would someone think that the assembler accepted their high, unsigned value when in reality it got flipped negative? One option would be to relax the range constraints for non-decimal numbers (octal or hex). But, the assembler currently has no bookkeeping for how an integer literal came into existence. A bit of extra machinery would be needed to track whether a numeric value came from a decimal, octal, or hex literal.
Unfortunately, this issue is going to remain a "won't fix" for the time being. Perhaps a v2 of the assembler could have the foresight to implement behavioral distinction between the various numeric literal formats.
from bronzebeard.
Actually, after digging a bit more into #11, I'm less worried about the "signedness surprise". Especially with 20-bit values. The actual fix for U-type instructions (AUIPC
and LUI
) was only a couple of lines. There is also some nuance to the immediate value given to C.LUI
that I plan to be flexible with, as well.
from bronzebeard.
Related Issues (19)
- db only accepts single values? HOT 1
- optimal li instruction HOT 4
- operand recognition in 0.1.7 HOT 1
- Progress Bar HOT 2
- Add support for writing basic macros HOT 7
- compressed LI error -> AssemblerError: constraint failed: imm must not be 0 HOT 12
- MV pseudo-instruction is not optimally assembled
- Is there any way to output .hex format instead of bb.out HOT 5
- CSR privilaged instructions HOT 2
- Add docs for CLI usage HOT 1
- Support for RV32EC (embedded) configuration? HOT 3
- A comment placed on the same line as an include directive gives an uninformative error HOT 1
- Assembler optimizations
- Assembler refactor HOT 2
- Better debug output
- More official documentation HOT 1
- It just works! HOT 1
- hexadecimal numbers as third operand HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bronzebeard.