Hello 

I had this bug since 3.60, that's why I stayed back to 3.50 for a while. 
I see 3.80 fixed some other bug I had, so I decided to send a report for this 
one. 

https://www.dropbox.com/s/zko66w2asxbboqa/test01.zip?dl=0


There is a place in my code (version that works or doesn't provided) where a 
line like this: 
for (y = 0; y<y0; y++) 
{ 
single_column[y] = 128; 
single_column[COL_MAX_HEIGHT - y - 1] = 64; 
} 

will result in assembly code that would do something like this 

for (y = 0; y<y0; y++) 
{ 
single_column[y] = 128; 
single_column[COL_MAX_HEIGHT - 1] = 64; 

} 

When debugging it seemed that the IY register is loaded with start address of 
single_column 
then BC is added to it, having value equal to 'y' so IY = &single_column[y] 
Then IY is preserved for the second line, it's not reset back to 
&single_column[0] 
and then BC=COL_MAX_HEIGHT-1 is calculated and added to IY, resulting to 
single_column[y + COL_MAX_HEIGHT -y -1] = single_column[COL_MAX_HEIGHT-1] 
so I always fill only element COL_MAX_HEIGHT-1 in the array and not the 
previous ones (screenshots of right and wrong memory in the zip also) 

Now, main0.c is the original with the bug, main1.c is a simplified version that 
keeps this code but removes the other parts that are not necessary. But this 
removal will simplify the code generation and the bug will not occure. I don't 
see anything wrong in the main1.c code from my programmer's logic, and this 
would work properly from 3.50 and before. 

Things like initing few local variables as unsigned instead of signed in this 
code would also fix it for me (it just alters the code generation and happens 
to not encounter the problem but I don't know when it happens) which is fine 
with me to continue with my project, but I decided to report this because it 
could cause more problems in the future and I hope things like that will be 
fixed in later versions. 

Thanks 

Michael Kargas 


_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to