array help using .byte[1]
Why wont this work ?
Where buffer is a long and tempvar is a byte. Count is a long, but just used to index my buffer
[b] tempvar := buffer [noparse][[/noparse] count ].byte [noparse][[/noparse] 2 ] [/b]
Where buffer is a long and tempvar is a byte. Count is a long, but just used to index my buffer

Comments
if buffer is an array of longs, just do:
tempvar := (buffer[noparse][[/noparse]count] & $00ff0000) >> 16
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Visit the home of pPropQL, pPropQL020 and OMU for the pPropQL/020 at omnibus.uni-freiburg.de/~rp92
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve
Propalyzer: Propeller PC Logic Analyzer
http://forums.parallax.com/showthread.php?p=788230
Here is a way to define an array as a long and access the individual bytes without having to do any additional multiplying or shifting. The only drawback is that you need to define your variables in the DAT section.
This example lights the corresponding LEDs on the Propeller DemoBoard
[b]CON[/b] [b]_clkmode[/b] = [b]xtal1[/b] + [b]pll16x[/b] [b]_xinfreq[/b] = 5_000_000 [b]PUB[/b] MainProgram|i,tempvar buffer[noparse][[/noparse]*0] := %11110011_11100111_11001100_10010010 buffer[noparse][[/noparse]*1] := %11111111_01010101_10101010_00011000 buffer[noparse][[/noparse]*2] := %00000011_00000111_00001111_00011111 buffer[noparse][[/noparse]*3] := %11000000_11100000_11110000_11111000 [b]dira[/b][noparse][[/noparse]*16..23]~~ [b]repeat[/b] i [b]from[/b] 0 to 15 tempvar := bufferBytes[noparse][[/noparse]*i] [b]outa[/b][noparse][[/noparse]*16..23] := tempvar [b]waitcnt[/b](clkfreq+[b]cnt[/b]) [b]DAT[/b] buffer [b]long[/b] bufferBytes [b]byte[/b] 0,0,0,0 '<-buffer[noparse][[/noparse]*0] [b]byte[/b] 0,0,0,0 '<-buffer[noparse][[/noparse]*1] [b]byte[/b] 0,0,0,0 '<-buffer[noparse][[/noparse]*2] [b]byte[/b] 0,0,0,0 '<-buffer[noparse][[/noparse]*3]...or, you can simplify the DAT section to something like this if you have a large array...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 5/22/2009 9:25:11 PM GMT