-
Notifications
You must be signed in to change notification settings - Fork 17
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
Variables with the same name as registers break Intel assembly #50
Comments
Interesting; it seems the intel dialect has quite a few of these cases due to it's ambiguous nature (no way in the syntax to determine whether something is a register, immediate, symbol, etc). I believe it's in the plans to mangle not only function names, but also variable names, with the caveat of anything |
I find the best solution to this problem is to ask GCC for advice |
... thanks GCC |
It seems that GCC avoids dealing w/ this by simply emitting object files instead 👁️ |
It’s worth noting that GCC uses AT&T by default, so it doesn’t normally suffer from this problem unless you use intel syntax |
NASM can deal with this problem it seems:
|
I guess the ‘solution’ to this is to disallow I guess the ‘easiest’ way of solving this issue would be to simply add a flag to the codegen context ( |
@LensPlaysGames Not sure how familiar you are w/ NASM, but I can take a look at implementing a NASM backend if you’d like 👀 |
Finally, this is definitely true and I doubt conflicts like this one would be common, but that doesn’t change the fact that 1. they’re possible, and 2. more assembler backends and options is probably a good idea anyway, because maybe someone would prefer to just use NASM or some other assembler... |
This is probably the first step to take; it would fix this issue for the default backend, and therefore for most users of the
I learned NASM first, then GAS. That's why LensorOS has a mix of NASM
I mean, don't let me stop you (support for more backends is always highly appreciated), but this isn't necessarily top priority to me. Personally, I envision that what will be most useful is an object file backend, as those object files can then be used by any assembler, compiler, linker, etc.; but that is an entire project in itself, hehe. However that's just my perspective: someone who doesn't really know C all that well would probably greatly appreciate a backend for an easier-to-obtain assembler like NASM (it has prebuilt binaries readily available, whereas binutils... yeah).
💯. It's only a bad thing to support more backends when it is something that won't be maintained. I think NASM is close enough to the existing default backend (GAS) that it really won't be too difficult to maintain; it'll basically be a translation job more than anything, when implementing new codegen. |
Seriously tho, I’m sort of familiar w/ object file layout, so that shouldn’t be too bad. ELF files that is. I happen to know that you’re at least somewhat familiar w/ COFF, so I’ll leave that up to you 👀 |
And adding an asm backend would just entail changing the directives, so that should be fairly simple imo |
I forgot for a second that this also entails assembling the code, so er, that might take a bit longer haha |
The machine_code branch takes care of this the same way GCC does; by emitting object files instead :P
|
I feel like if GCC doesn’t handle this case, then we don’t really need to care too much about handling it either. I recall LLVM-generated assembly not being particularly compilable either if you use... less orthodox label names... |
#66 has closed, |
When compiling with
--dialect intel
no warnings/errors are produced and the following code is generated:Same as in #46, the issue only occurs during assembly:
The text was updated successfully, but these errors were encountered: