Comments (5)
I forgot to mention there's an undocumented #labelalign
directive, which might come in handy here? When you specify it, the assembler will automatically align every global label you define. So for example:
#bits 8
#labelalign 32
#ruledef
{
hlt => 0x33
}
hello:
#d "Hello"
code:
hlt
This would be interpreted as if there was an #align 32
directive right before each of hello:
and code:
, so code
will actually start at address 0x8
. (Non-global labels are not affected, though.)
Does this help the issue everyone is having here? I should add it to the documentation.
from customasm.
That's a good idea! I hadn't even realized that would be a problem.
Any possibility that the user would want this (broken) behavior instead?
from customasm.
I don't believe that there would be any reason for anyone to want this type of behavior.
from customasm.
For ISAs with a minimum addressable data size that is not 8-bits, this suggestion sounds reasonable. I have found that #bits
is usually not the right tool, however.
I am working with MIPS at the moment, where all instructions are 32 bits wide. But the minimum addressable data size is 8 bits. For this architecture, #bits 32
is incorrect. That said, I would still like a way, in general, to pad some data types (like strings) up to a specific alignment. Currently, I have to do this manually:
hello:
#align 32
#d "Hello, world!\0"
version:
#align 32
#d "Version: 1.0.0\0"
It is also still useful to not align after strings, in cases where you want to tightly pack the data.
It's easy to forget to include an alignment directive following data types with sizes that are not divisible by the minimum instruction width. For that reason, I think adding a new directive to specify instruction width (not data width) will be useful, but I don't think even that solves this particular case (which involves data).
Maybe a new directive to both align and output data is needed? Or an extension to the #d
directive which adds a padding parameter?
from customasm.
I believe that addresses the specific issue I brought up in this thread. It looks like the label alignment can be temporarily made smaller for packing structs, also.
from customasm.
Related Issues (20)
- Autoamtically resolve "multiple matches with the same output size" errors HOT 2
- Disambiguate instructions with whitespace differences HOT 10
- VSCode Syntax highlighting not working. HOT 2
- Add option for addressing units when outputting intelhex? HOT 1
- `#struct` Directive HOT 2
- Way to Include Raw Binary File HOT 1
- EBNF for customasm syntax HOT 4
- Feature Request: Compile for MacOS in release section. HOT 2
- Relative Jumps? HOT 2
- Are there any stability guarantees if I use customasm as a library? HOT 3
- Stack overflow / Index out of bounds with recursive rules
- v0.11 syntax error using a'b instead of b`a syntax for a constant with a specified width HOT 2
- Feature: adding space separated format
- Internal Overhaul
- "Unknown variable" when forwarding primitive arguments HOT 3
- no-color option HOT 2
- no match for instruction found HOT 2
- Feature Request: Different number base options for annotated text output. HOT 3
- Calculate `.len` of labels automatically
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 customasm.