Comments (5)
For now, I don't think so(?), so the best way would just be to use 0b0000_0000
, and just remember which bit is which reg which isn't too hard.
from customasm.
Yes, it's not too bad. Hopefully it'll support this kind of thing soon.
I guess I could feed my assembly through CPP and use some macros.
from customasm.
One way you could do this is by defining the registers as constants and then asking for an integer as the register list.
R0 = 1
R1 = 2
R2 = 4
R3 = 8
R4 = 16
R5 = 32
R6 = 64
R7 = 128
#cpudef "test"
{
#bits 8
#tokendef REG
{
r0 = 1
r1 = 2
r2 = 4
r3 = 8
r4 = 16
r5 = 32
r6 = 64
r7 = 128
}
popmulti {register_list: u8}, ( {ea: REG} ) -> 0xABCD @ register_list @ ea[7:0]
}
This way popmulti R0+R1+R3+R4+R5+R6,(r7)
becomes 0xABCD7B80
.
You can also define the constants in lowercase and it would work fine in most cases, but if you've got an instruction with the same mnemonic and multiple addressing modes (like if both mov r0, r3
and mov r0, 123
are legal) you should keep them uppercase or the assembler will get confused.
Also, if you don't need your instruction to use the +
sign and you are willing to be more flexible, you could do stuff like
popmulti ALL_REGS - R3, (r7)
(with ALL_REGS = 0xFF
) or typing the registers out of order. However, I would recommend using the |
sign instead of +
, in case you accidentally type a register twice (popmulti R1 + R1, (r7)
gets interpreted as R2
since 2+2=4, popmulti R1 | R1, (r7)
gets reduced to just R1
since 2|2=2).
from customasm.
That works well, thanks! Much easier then bringing out CPP. Using an or to bring them together seems the sensible approach.
I'm not sure if there's a general solution to this case.
Man, I might have a reason to learn Rust now.
from customasm.
I'm closing this since it can be achieve like p-rivero suggested or with recursive rules in newer versions! Feel free to open this issue again if you still need help.
from customasm.
Related Issues (20)
- VSCode Syntax highlighting not working. HOT 2
- Add option for addressing units when outputting intelhex? HOT 1
- Error with misaligned string ends. HOT 5
- `#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
- Cannot reference variables in #bankdef HOT 2
- Asserts in subruledefs are ignored when calling asm{...} HOT 2
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.