
Originally Posted by
mrx23
I want to send 64 pieces of bits-> so its 8 bytes
I think its ok Frame var byte[7] because 0-7 8 pieces of bytes->8*8=64 bits.
Your not understanding how PBP sets up arrays. When you declare the array, the first element gets assinged an address in the pics RAM. When you access that array, PBP starts at the beginning address, then adds to that address the element number you are accessing.
Code:
Frame var byte[7]
OtherByte var Byte
Frame[0] = 1 ; Address = Frame + 0
Frame[1] = 2 ; Address = Frame + 1
Frame[2] = 3 ; Address = Frame + 2
Frame[3] = 4 ; Address = Frame + 3
Frame[4] = 5 ; Address = Frame + 4
Frame[5] = 6 ; Address = Frame + 5
Frame[6] = 7 ; Address = Frame + 6
;--------------------------------------
; Outside the Array
Frame[7] = 8 ; Address = Frame + 7
; which will also be = OtherByte
Here is how PBP actually output:
Code:
; Frame var byte[7]
_Frame EQU RAM_START + 018h
; OtherByte var Byte
_OtherByte EQU RAM_START + 01Fh
; frame[0] = 1 ; Address = Frame + 0 (18h)
MOVE?CB 001h, _Frame
; frame[1] = 2 ; Address = Frame + 1 (19h)
MOVE?CB 002h, _Frame + 00001h
; frame[2] = 3 ; Address = Frame + 2 (1Ah)
MOVE?CB 003h, _Frame + 00002h
; frame[3] = 4 ; Address = Frame + 3 (1Bh)
MOVE?CB 004h, _Frame + 00003h
; frame[4] = 5 ; Address = Frame + 4 (1Ch)
MOVE?CB 005h, _Frame + 00004h
; frame[5] = 6 ; Address = Frame + 5 (1Dh)
MOVE?CB 006h, _Frame + 00005h
; frame[6] = 7 ; Address = Frame + 6 (1Eh)
MOVE?CB 007h, _Frame + 00006h
; frame[7] = 8 ; Address = Frame + 7 (1Fh) which also = OtherByte
MOVE?CB 008h, _Frame + 00007h
When you assing a value (or read a value) to Frame[7], you are actually going to access a RAM address beyond the array. Not a big deal IF no other values have been assigned to that address. Not likely in any real program.
So yes, it works, sort of. It doesn't cause an error at compilation, but you will almost certianly get runtime errors from such a setup. Take Steve's (Mister_e, the other Steve
) advice, change your array declaration to:
Frame VAR BYTE[8]
Steve
EDIT: With arrays of WORDs, PBP just adds 2 to the starting address for each element that you are accessing.
Bookmarks