So, despite warnings not to, I decided to give ZDSII a try for some generic (not calculator related) and fairly trivial tests.
I have the following small program:
Code:
The compiler turns this into
Code:
i.e. at the end of the do/while loop, the code first decrements i, then explicitly compares its value to zero, and then does a conditional jump.
Shouldn't the compiler be able to skip the explicit comparison, as DEC (IX/Y+d) changes the zero flag according to the result of the decrement?
I have the following small program:
Code:
volatile signed char vvar;
void main(void)
{
unsigned char i;
i=8;
do
{ vvar++; }
while((unsigned char) --i != (unsigned char) 0);
return;
}
The compiler turns this into
Code:
PUSH IX
LD IX,0
ADD IX,SP
DEC SP
; 5 unsigned char i;
; 6
; 7 i=8;
.LINE 7
LD (IX+%FFFFFFFF),%8
; 8 do
L_1:
.LINE 8
; 9 { vvar++; }
.LINE 9
LD A,(_vvar)
LD B,A
LD A,(_vvar)
INC A
LD (_vvar),A
; 10 while((unsigned char) --i != (unsigned char) 0);
.LINE 10
DEC (IX+%FFFFFFFF)
LD A,(IX+%FFFFFFFF)
OR A,A
JR NZ,L_1
; 11
; 12
; 13 return;
.LINE 14
LD SP,IX
POP IX
RET
i.e. at the end of the do/while loop, the code first decrements i, then explicitly compares its value to zero, and then does a conditional jump.
Shouldn't the compiler be able to skip the explicit comparison, as DEC (IX/Y+d) changes the zero flag according to the result of the decrement?