cognew return value optimizer error
Mike Petry
Posts: 14
I ran into an issue where the return value of cognew appeared in error. It popped up working on a port of Chip's VGA_HiRes_Text.spin code. I traced it back to an optimizer issue -Os vs. -O0. I simplified it to the attached example of cognewing two instances of a .DAT consisting of a simple loop. In the -O0 case, I get back the expected "1 2" case. In the -Os it gives back "1 1". It seems that the definition of the built-in needs to be marked as being volatile so the optimizer will not try to be so helpful.
extern uint32_t binary_cogcode_dat_start[];
i = cognew((uint32_t) binary_cogcode_dat_start, (uint32_t)0);
printf("%d\n",i);
j = cognew((uint32_t) binary_cogcode_dat_start, (uint32_t)0);
printf("%d\n",j);
cogopt.zip
extern uint32_t binary_cogcode_dat_start[];
i = cognew((uint32_t) binary_cogcode_dat_start, (uint32_t)0);
printf("%d\n",i);
j = cognew((uint32_t) binary_cogcode_dat_start, (uint32_t)0);
printf("%d\n",j);
cogopt.zip
zip
826B
Comments
Eric