<div dir="ltr"><div><div>People coming from 8-bitters will often think they are saving space/speed etc by using 8-bit or 16-bit values as counters, flags etc.<br><br></div>Don't do that. It costs more (in terms of both space AND execution time) to use 8-bit and 16-bit values than to use 32-bit values.<br><br><br></div><div>The reason for this is that ARM does 32 bit calculations. If you ask for 8-bit semantics then the operation must be truncated to match 8-bit semantics.  (therefore more code, more instruction execution time...) <br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 12, 2016 at 10:16 AM, Robin Gilks <span dir="ltr"><<a href="mailto:robin@gilks.org" target="_blank">robin@gilks.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
> Hi Robin<br>
><br>
> I've done lots of work with ARM (probably coming up 20 years now). I've<br>
> never seem something like that. Nor does it raise any aha! flags. ARM is<br>
> generally a very well behaved 32 bit architecture.<br>
><br>
> arm gcc is also generally a very good compiler with very few issues. All<br>
> the phone sw in an iphone or android is built with it.<br>
><br>
> If you're still stuck, feel free to send more specific questions my way.<br>
><br>
> First things first... In general packing is not a good idea for two<br>
> reasons:<br>
><br>
> 1) Less people do packing therefore more likely to expose "interesting"<br>
> behaviour.<br>
> 2) Packing very seldom saves space.<br>
><br>
> But that's probably not your problem...<br>
><br>
> Start off by building with the following flags<br>
> -Wall  all warnings<br>
> -Wextra even more warnings<br>
> -Werror   make all warnings into errors<br>
> -O0     No optimisation for now.<br>
><br>
> In general those will pull up any programmer daftness. Saved my bacon many<br>
> times :-).<br>
><br>
> -- Charles<br>
><br>
<br>
</span>Found it!!<br>
<br>
Wall and Werror nailed it.<br>
<br>
Immediately after loading the data from external Flash I was doing a CRC<br>
of it to check its integrity. Simple enough, it looks like this:<br>
<br>
    crc = CRC_CCITT_INIT_VAL;<br>
    p = (uint8_t *)RegPointer;<br>
    for (i = 0; i < sizeof(RegisterFile); i++)<br>
       crc = updcrc_ccitt(*p, crc);<br>
<br>
Trouble is, when you declare 'i' like this<br>
uint8_t i;<br>
<br>
its not obvious that the "i < sizeof(RegisterFile)" clause is always true<br>
when the data size is > 256 due to the limitation of the size of 'i'.<br>
Quite rightly the compiler made that condition always true by putting in<br>
an infinite loop!!<br>
<br>
So easy to miss a declaration half a page away! Now I know to check the<br>
manipulations to all my references to the config data are not restricted<br>
to 8 bits and to keep the extra warning flags in the Makefile!!<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Robin Gilks<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
<br>
<br>
______________________________<wbr>_________________<br>
Chchrobotics mailing list <a href="mailto:Chchrobotics@lists.linuxnut.co.nz">Chchrobotics@lists.linuxnut.<wbr>co.nz</a><br>
<a href="http://lists.ourshack.com/mailman/listinfo/chchrobotics" rel="noreferrer" target="_blank">http://lists.ourshack.com/<wbr>mailman/listinfo/chchrobotics</a><br>
Mail Archives: <a href="http://lists.ourshack.com/pipermail/chchrobotics/" rel="noreferrer" target="_blank">http://lists.ourshack.com/<wbr>pipermail/chchrobotics/</a><br>
Meetings usually 3rd Monday each month. See <a href="http://kiwibots.org" rel="noreferrer" target="_blank">http://kiwibots.org</a> for venue, directions and dates.<br>
When replying, please edit your Subject line to reflect new subjects.<br>
</div></div></blockquote></div><br></div>