byte arrays...
Can anyone help me with this problem.
I have some code which uses a 12 byte array, I have found that the stamp editor will not recognise high and low nibbles of bytes if they are from a byte array. eg..
'This works...
databyte var byte
databyte = 25
debug dec databyte,highnib
'shows "1" on pc screen
'This doesnt work
databyte var byte(12)
databyte(3) = 25
debug dec databyte(3).highnib
It hangs up when tokenising, and shows "Expected]" at the fullstop before highnib on the debug command line
Any help would be greatly appreciated
Regards, Chris Anderson
I have some code which uses a 12 byte array, I have found that the stamp editor will not recognise high and low nibbles of bytes if they are from a byte array. eg..
'This works...
databyte var byte
databyte = 25
debug dec databyte,highnib
'shows "1" on pc screen
'This doesnt work
databyte var byte(12)
databyte(3) = 25
debug dec databyte(3).highnib
It hangs up when tokenising, and shows "Expected]" at the fullstop before highnib on the debug command line
Any help would be greatly appreciated
Regards, Chris Anderson
Comments
fes@g... writes:
> I have some code which uses a 12 byte array, I have found that the stamp
> editor will not recognise high and low nibbles of bytes if they are from a
> byte array. eg
You can define a nibble array that overlays the byte array.
displaying byte arrays in nibble format, each nibble in a byte array is
actually a "lownib" for debugging or serout purposes, I found the answer in
the stamp manual.
thanks, Chris
Original Message
From: <jonwms@a...>
To: <basicstamps@egroups.com>
Sent: Tuesday, November 14, 2000 9:18 PM
Subject: Re: [noparse][[/noparse]basicstamps] byte arrays...
> In a message dated 11/14/00 4:19:49 AM Central Standard Time,
> fes@g... writes:
>
> > I have some code which uses a 12 byte array, I have found that the stamp
> > editor will not recognise high and low nibbles of bytes if they are from
a
> > byte array. eg
>
> You can define a nibble array that overlays the byte array.
>
>
editor will not recognise high and low >nibbles of bytes if they are from a
byte array. eg..
>
>'This works...
>databyte var byte
>databyte = 25
>debug dec databyte,highnib
>'shows "1" on pc screen
>
>'This doesnt work
>databyte var byte(12)
>databyte(3) = 25
>debug dec databyte(3).highnib
It may be easier _not_ to declare the array expicitly. Three words defined
in a row can be accessed _implicitly_ as an overlay array of 3 words, 8
bytes, or 16 nibs...
dataword var word ' three word implicit array
dataword1 var word
dataword2 var word
databyte var dataword.byte0 ' alias for bytes
datanib var dataword.nib0 ' alias for nibs
dataword=$0001
dataword1=$0002
dataword2=$0003
'display 3 words 1234
for i=0 to 3
debug ? dataword(i)
next
'display 8 bytes 1,0,2,0,3,0 (low byte first!)
for i=0 to 5
debug ? databyte(i)
next
'display 16 nibs 1,0,0,0,2,0,0,0,3,0,0,0
for i=0 to 15
debug ? datanib(i)
next
As you noticed, the BASIC Stamp editor does not let you go the other way,
that is, you cannot declare an alias for an explicitly defined array
element.
-- Tracy Allen
http://www.emesystems.com
I have a 12 byte array, and I need to serout bytes 0, 1 and 2 as nibbles to
an lcd display, I have done it as follows.
serout
etc.....[noparse][[/noparse]databyte.lownib(0),databyte.lownib(1),databyte.lownib(3),databyte.l
ownib(4),etc...]
This works fine, I need the byte array as I gather the 12 bytes of data from
memory in a for / next loop.
Also can you give any thought to making the stache stop writing at the end
of programming, rather than filling in all 0's where data may be stored.
Regards and thanks
Chris Anderson
Original Message
From: Tracy Allen <emesys@c...>
To: <basicstamps@egroups.com>
Sent: Wednesday, November 15, 2000 1:19 AM
Subject: [noparse][[/noparse]basicstamps] byte arrays...
> >I have some code which uses a 12 byte array, I have found that the stamp
> editor will not recognise high and low >nibbles of bytes if they are from
a
> byte array. eg..
> >
> >'This works...
> >databyte var byte
> >databyte = 25
> >debug dec databyte,highnib
> >'shows "1" on pc screen
> >
> >'This doesnt work
> >databyte var byte(12)
> >databyte(3) = 25
> >debug dec databyte(3).highnib
>
> It may be easier _not_ to declare the array expicitly. Three words
defined
> in a row can be accessed _implicitly_ as an overlay array of 3 words, 8
> bytes, or 16 nibs...
>
> dataword var word ' three word implicit array
> dataword1 var word
> dataword2 var word
> databyte var dataword.byte0 ' alias for bytes
> datanib var dataword.nib0 ' alias for nibs
>
> dataword=$0001
> dataword1=$0002
> dataword2=$0003
>
> 'display 3 words 1234
> for i=0 to 3
> debug ? dataword(i)
> next
>
> 'display 8 bytes 1,0,2,0,3,0 (low byte first!)
> for i=0 to 5
> debug ? databyte(i)
> next
>
> 'display 16 nibs 1,0,0,0,2,0,0,0,3,0,0,0
> for i=0 to 15
> debug ? datanib(i)
> next
>
> As you noticed, the BASIC Stamp editor does not let you go the other way,
> that is, you cannot declare an alias for an explicitly defined array
> element.
>
> -- Tracy Allen
> http://www.emesystems.com
>
>
>of programming, rather than filling in all 0's where data may be stored.
Hi Chris,
I think this is what you mean: The Stache uploads program banks on an
all-or-nothing basis, filling in undeclared bytes with zeros. It does not
sub-allocate 16 byte blocks within each bank. Please send me email off list
with more details of what you are trying to accomplish.
A possible workaround for the BS2sx and BS2e is to store parameter data in
its own bank, so that you can load parameters without affecting other
program banks, or so that you can load new programs without affecting
parameters.
-- Tracy Allen
http://www.emesystems.com/stachedat.htm <-- Stache info