"C:\Program Files\SDCC\bin\sdcc.exe" SPIFlash.c -c -mpic16 -p18F452 --obanksel=2 --optimize-cmp --optimize-goto --optimize-df -dD
SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.7.0 #4818 (May 31 2007) (MINGW32)
Optimization is on (see command line above)
The two sections below should work the same.
Section One Always Works as expected.
Section Two Works as expected except if length is 1, thereby making --length zero.
if length is 1, bitmap ends up as 0x00000000, expected is 0xFFFFFFFE
This code converts a string length to a double word bit map with each bit representing 8 bytes of a 256 byte buffer
unsigned long bitmap;
unsigned char length;
bitmap = 0xFFFFFFFF; //Section one
bitmap <<= length;
bitmap = 0xFFFFFFFF; //Section two
bitmap <<= ++length;