Closed cocoacrumbs closed 2 years ago
Sounds like you were able to fix the issue.
Added some related flags, eventually some "asm format" (or the already existing asm variant) flag should be added that affects the default.
$ cat offset-format.c
void test(void) {
char *iy;
asm("": "=y"(iy));
asm("":: "r"(iy), "r"(iy - 2));
}
$ for zero in "=false" ""; do
for neg in "false" "true"; do
ez80-clang -O1 -S offset-format.c -o - -mllvm -z80-print-zero-offset$zero -mllvm -z80-add-negative-offset=$neg
done
done | grep "lea\|:$"
_test:
lea hl, iy - 2
lea de, iy
_test:
lea hl, iy + -2
lea de, iy
_test:
lea hl, iy - 2
lea de, iy + 0
_test:
lea hl, iy + -2
lea de, iy + 0
I'm just passing the flag value differently to demonstrate both syntaxes, either syntax works with either flag (and also 1/0 instead of true/false).
Thanks,
I quickly rebuild the tool chain and tried with the -mllvm -z80-print-zero-offset
flag and assembly went fine (it complained when I tried it first without that flag so I'm sure the flag works as intended).
Hi,
I'm trying to create a complete eZ80 tool chain based on your work and using the Z80 binutils (version 2.37) for assembling and linking (as is done by NuttX as well). For this to work, I applied the changes made by codebje to have bin utils compatible syntax (I had to make some fixes for that as well). My personal hope is that we then get a nice tool chain for an affordable, eZ80 based 8 bit computer which would allow us to port bigger applications (e.g. Lua would be nice but can't be compiled with the Zilog ZDS II tools).
I'm in the process of adapting the ZDS II code to work with this setup to have some minimal C library to build upon.
The first issue I stumbled upon is that when an offset is 0, it's not printed. E.g.:
would be
Unfortunately, the bin utils assembler (
ez80-none-elf-as
) doesn't like this syntax and quits.After a bit of searching I found a simple fix:
Now, the offset is always printed and the assembler is happy.
I do have 2 other, more serious problems:
__attribute__((__interrupt__))
does not generate correct code. At this moment, I'm able to generate the needed instructions but I see that offsets in the stack for the variables are wrong and I can't find a solution for that (it's the first time I'm looking into the code for a compiler and it's a bit overwhelming).I'll write up more detailed reports for that.
Koen