-
Notifications
You must be signed in to change notification settings - Fork 171
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
sdcc generates invalid opcode ld h,iyl #1977
Comments
Not sure it is a bug, as your reference describes it. edit Not true. I misread instruction issued.
But, afaik and as described in other issues (eg #1504) |
mmm I'm not sure the lines you mention apply to the instruction which is generated. In any case, I believe it is a bug because:
So either it is a Z80ASM bug, or a ZSDCC one. Don't you agree? ;-) |
It looks like if assembled it would act as ld iyh,iyl which is not what is intended from the rest of the snippet. So I’m backing sdcc rather than z80asm issue. |
If you can reproduce it in a short section of code, targeting They are closing a stable release window in next days. |
I've got a "minimal" example. It's seems related to the size of the structures. Compile: Removing --max-allocs-per-node also sidesteps the issue.
Need to verify that this also happens in vanilla upstream. Edit: After fixing the sdcc trunk so that sdcc will build, the issue can be reproduced upstream. Raised bug: https://sourceforge.net/p/sdcc/bugs/3327/ |
Well, thanks so much to all involved, It never ceases to amaze me how I can report a bug at 2pm and have it solved and patched on the same day at 23.30. This is what makes me love free software. Cheers |
The solution for #1977 is now in the 4.2.0 PR patch, but will be removed once it flows into the 4.2.0 RC. |
@feilipu, while restoring the MZ800 MONITOR and BASIC sources I noticed that the (mz-5z009) uses different opcodes than z80asm: LD IY,DE was originally translated to $d5, $fd, $e1 ..while z88dk-z80asm uses: Obviously the IX prefix should work similarly. I don't know if the shorter sequence is valid on all the Z80 CPUs or only on the LH-0080, though. EDIT: |
the shorter sequence is |
Moreover it relies on the stack, and the side effect of changing a word in ram could be unwanted by the coder |
Apparently, when compiling some C code with SDCC, an invalid opcode is generated:
When examining the ASM generated by the C source, the invalid opcode is indeed there:
I know that "ld h, iyl" is an undocumented instruction, but according to this reference, it is not a valid one due to ambiguity. And Z80ASM does not chew it (correctly, it seems).
Compilation options:
zcc +zx -compiler=sdcc
Compilation with
-SO3 --opt-code-size
and without makes no difference.I'm not sure how to reproduce the bug, since the assignment instruction seems pretty simple, so it looks that this is a combinatioj of factors involved that lead to this error.
Happy to do any tests to hunt this down.
Update: if I compile with the
--reserve-regs-iy
option, the problem disappears, as expected.The text was updated successfully, but these errors were encountered: