a minimal, complete and verifiable example MCVEwhy reading from a bit array from arbitrary position (not byte justified) returns garbage?
https://stackoverflow.com/help/minim...ucible-example
here is one that shows no problem at all pbp3, examination of lst file confirms reservation of the 4 bytes required for the bit array
if there was ever any doubt
printoutCode:; pbp3 16f1825 define OSC 32 #CONFIG __config _CONFIG1, _FOSC_INTOSC & _CP_OFF & _WDTE_OFF & _PWRTE_ON & _MCLRE_ON & _CLKOUTEN_OFF __config _CONFIG2, _PLLEN_ON & _LVP_OFF #ENDCONFIG DEFINE DEBUG_REG PORTA DEFINE DEBUG_BIT 0 DEFINE DEBUG_BAUD 9600 DEFINE DEBUG_MODE 0 OSCCON=$70 ANSELA=0 ANSELC=0 barray var bit[32] bbyte var byte ext another var word cnt var byte tst var bit more var byte @bbyte = PBA01 clear bbyte[0]=5 bbyte[1]=$55 lata.0=1 pause 2000 Debug "Start",13 ,10 for cnt=31 to 0 step -1 Debug #barray[cnt] next Debug " array by bit",13 ,10 for cnt =3 to 0 step -1 Debug bin8 bbyte[cnt] next barray[11] =1 Debug " array by byte in bin",13,10,"set bit 11",13 ,10 for cnt=31 to 0 step -1 Debug #barray[cnt] next Debug 13 ,10 for cnt =3 to 0 step -1 Debug bin8 bbyte[cnt] next bbyte[3] =255 Debug 13 ,10,"set byte 3",13 ,10 for cnt=31 to 0 step -1 Debug #barray[cnt] next Debug 13 ,10 for cnt =3 to 0 step -1 Debug bin8 bbyte[cnt] next barray[11] =0 Debug 13 ,10,"clr bit 11",13 ,10 for cnt=31 to 0 step -1 Debug #barray[cnt] next Debug 13 ,10 for cnt =3 to 0 step -1 Debug bin8 bbyte[cnt] next bbyte[3] =0 Debug 13 ,10,"clr byte 3",13 ,10 for cnt=31 to 0 step -1 Debug #barray[cnt] next Debug 13 ,10 for cnt =3 to 0 step -1 Debug bin8 bbyte[cnt] next
Start
00000000000000000101010100000101 array by bit
00000000000000000101010100000101 array by byte in bin
set bit 11
00000000000000000101110100000101
00000000000000000101110100000101
set byte 3
11111111000000000101110100000101
11111111000000000101110100000101
clr bit 11
11111111000000000101010100000101
11111111000000000101010100000101
clr byte 3
00000000000000000101010100000101
00000000000000000101010100000101




Bookmarks