Constant Array SX/B
Vinchi
Posts: 4
Hello!
I dont know hove to make an constant array in SX/B? Something dont work. I am only strating with SX.
Is it possible to make constant array like in C?
const char test[noparse]/noparse = {
11111111b,
11111110b,
11111110b,
00000000b,
00000000b,
11111110b,
11111110b,
11111111b,
00000000b};
I dont know hove to make an constant array in SX/B? Something dont work. I am only strating with SX.
DEVICE SX52, OSC4MHZ ', TURBO, STACKX, OPTIONX FREQ 4_000_000 ' ========================================================================= PROGRAM Start ' ========================================================================= counter VAR byte LED VAR RD MASIVS VAR BYTE(8) MASIVS(0) = %00000001 MASIVS(1) = %00000010 MASIVS(2) = %00000100 MASIVS(3) = %00001000 MASIVS(4) = %00010000 MASIVS(5) = %00100000 MASIVS(6) = %01000000 MASIVS(7) = %10000000 Start: TRIS_A = %00000000 TRIS_B = %00000000 TRIS_C = %00000000 TRIS_D = %00000000 TRIS_E = %00000000 Main: FOR counter = 0 TO 7 LED = MASIVS(counter) PAUSE 1 NEXT GOTO START
Is it possible to make constant array like in C?
const char test[noparse]/noparse = {
11111111b,
11111110b,
11111110b,
00000000b,
00000000b,
11111110b,
11111110b,
11111111b,
00000000b};
Comments
LOOKUP counter,%00000001,%00000010,%00000100,%00001000,%00010000,%00100000,%01000000,%10000000,LED
For larger tables use DATA and READ
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
Product web site: www.sxvm.com
Available now... SX-Video OSD module $59.95 www.sxvm.com
Life is NOT a box of chocolates.
Life is a journey, and 99% of the time you get where your headed.
·
Since there are no constant arrays in SX/B, you must move your assignments inside the execute path.
For example:
DEVICE SX52, OSC4MHZ
', TURBO, STACKX, OPTIONX
FREQ 4_000_000
' =========================================================================
PROGRAM Start
' =========================================================================
counter VAR byte
LED VAR RD
MASIVS VAR BYTE(8)
Start:
MASIVS(0) = %00000001
MASIVS(1) = %00000010
MASIVS(2) = %00000100
MASIVS(3) = %00001000
MASIVS(4) = %00010000
MASIVS(5) = %00100000
MASIVS(6) = %01000000
MASIVS(7) = %10000000
TRIS_A = %00000000
TRIS_B = %00000000
TRIS_C = %00000000
TRIS_D = %00000000
TRIS_E = %00000000
Main:
FOR counter = 0 TO 7
LED = MASIVS(counter)
PAUSE 1
NEXT
GOTO Main
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
Product web site: www.sxvm.com
Available now... SX-Video OSD module $59.95 www.sxvm.com
Life is NOT a box of chocolates.
Life is a journey, and 99% of the time you get where your headed.
·