z80 3.5.2 #9283 (Linux, snapshot)
Simple read/write operations on a __sfr, can crash the compiler easily when "--reserve-regs-iy" is specified.
Building the following code
__sfr __at 0x06 bank_a_page; static unsigned char page_current; int main(void) { page_current = bank_a_page; bank_a_page = page_current; return 0; }
with
$ sdcc debug.c -o debug -mz80 --reserve-regs-iy
leads to
debug.c:10: error 9: FATAL Compiler Internal Error in file '../../../src/z80/gen.c' line number '737' : code generator internal error Contact Author with source code debug.c:10: error 9: FATAL Compiler Internal Error in file '../../../src/z80/gen.c' line number '742' : Trying to assign a value to a literal Contact Author with source code debug.c:10: error 9: FATAL Compiler Internal Error in file '../../../src/z80/gen.c' line number '737' : code generator internal error Contact Author with source code debug.c:10: error 9: FATAL Compiler Internal Error in file '../../../src/z80/gen.c' line number '742' : Trying to assign a value to a literal Contact Author with source code ld_cost op1: AOP_HL, op2: 4ld_cost op1: AOP_HL, op2: 4
Small bump to indicate the bug is still present for the z80 in 3.5.6 #9605 (MINGW64).
sdcc -mz80 -S --reserve-regs-iy test.c
ld_cost op1: AOP_HL, op2: 4ld_cost op1: AOP_HL, op2: 4ld_cost op1: AOP_HL, op2: 4ld_cost op1: AOP_HL, op2: 4
zzzz.c:13: error 9: FATAL Compiler Internal Error in file '/home/sdcc-builder/build/sdcc-build/orig/sdcc/src/z80/gen.c' line number '740' : code generator internal error
Contact Author with source code
The bug only occurs for reading the i/o port into a global variable. If "a" is made local, there is no error. The difference is in the latter case, the result of the port read can be stored in an ix-indexed location whereas in the former case, sdcc insists on using iy to point at "a" and store the result which it can't do with "--reserve-regs-iy".
Fixed in [r9711]