-
-
Notifications
You must be signed in to change notification settings - Fork 175
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
[Feature request] Link-time conditionals for identically sized branches #822
Comments
I like it. I wonder how complex RPN-based relocations would get, though. |
Sadly, this precondition isn't sufficient:
Both branches produce exactly 0 bytes, so they fulfill the precondition, but then |
That's not a problem; the second definition would fail since
|
ISSOtm suggested " Alternatively, maybe |
That last syntax is what I had in mind, yep. The last branch is mandatory, obviously! |
I was hoping for regular |
Like this? UNION IF x == -1
jr c, .foo
NEXTU IF x == 0 ; "elif"
jr z, .foo
NEXTU IF x == 1 ; "elif"
jr nc, .foo
NEXTU ; "else"
jr .foo
ENDU ; "endc" |
I believe that would be problematic given how |
Generating code with macros, like pokecrystal16, can require different optimizations depending on where labels end up being placed. (Note the various
db
s in that file.) However,if
needs to be evaluated at assembly time, and an eventual ternary operator would only work withindb
s, requiring people to encode instructions as raw bytes. (For instance,db (HIGH(\1EntriesEnd) & 1) ? $28 : $20, .search_loop - (@ + 1)
, would eventually work, but(HIGH(\1EntriesEnd) & 1) ? <jr nz, .search_loop> : <jr z, .search_loop>
, orjr <(HIGH(\1EntriesEnd) & 1) ? nz : z>, .search_loop
, cannot.)A solution could be link-time conditionals. These would fail to assemble if all their branches are not already the same size, or if one branch defines a label but another does not. (Two branches defining a label in different relative locations should be okay, I think, but if it isn't that would be fine as a limitation too.)
Example syntax (chosen in contrast with
static_assert
):The text was updated successfully, but these errors were encountered: