The reason is because the variable a is not modified inside the loop, so
the compiler may optimise that away by doing a jump to self instead of
anding and jumping to self if not zero, or it may cache the value of the
variable somewhere and do the same. If the variable is modified somewhere
else, namely an interrupt, the behaviour will not be the desired one.
Declaring it as volatile will ensure the resulting assembly will read the
value of the variable every time before anding. That should be 0x800001, by
the way.
On Oct 24, 2012 2:16 AM, "mind entropy" <mindentr...@gmail.com> wrote:
> Hi,
>
> I was reading the mspgcc manual (
>
> http://www.eecs.harvard.edu/~konrad/projects/motetrack/mspgcc-manual-20031127.pdf
> )
> and on Pg 39 its written as
>
> "If you execute
> while ((long) a & 0x80000l);
> the program will hang, unless ’a’ is declared volatile. So, do it!"
>
> I did not get it. Why should it hang?
>
> Thanks,
> Gautam.
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_sfd2d_oct
> _______________________________________________
> Mspgcc-users mailing list
> Mspgcc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users
>
>
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users