simple SX/B question
Alex Hunter
Posts: 18
Hello, i'm new to the SX, and i have a simple question that i can't figure out.
I would like to use code similar to the following:
I would like to use a variable to identify a pin. But this code doesn't work. Is there some way i can get something like this to work, without using if-then statements?
Thanks,
Alex Hunter
I would like to use code similar to the following:
for idx = 0 to 7 HIGH RA.idx next
I would like to use a variable to identify a pin. But this code doesn't work. Is there some way i can get something like this to work, without using if-then statements?
Thanks,
Alex Hunter
Comments
My apologies gang.· I just realized that my answer was so far off that it was flat out wrong ... thus I deleted it so that it doesn't get used.· Bean gave much better advice in the next message.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John J. Couture
San Diego Miramar College
Post Edited (John Couture) : 8/3/2006 5:36:29 AM GMT
· You cannot use a variable for the bit position. This is because of the way the SX instructions are formed.
· Probably the easiest way is to do this:
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
"You're braver than you believe, stronger than you seem, and smarter than you think" Christopher Robin to Pooh
·
I found your trick the hard way last week. I thought I was real stupid finding no other way but by using the OR function. it makes me feel a little better seeing you're using it.
John Bond
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
"You're braver than you believe, stronger than you seem, and smarter than you think" Christopher Robin to Pooh
·
Using the 'Bean' strategy, is there a similar way we can access the individual bits using an index, instead of shifting a byte?
For example if I wanted to test individual bits of a byte:
idx VAR BYTE
mybyte VAR BYTE
FOR idx = 0 TO 7
IF mybyte.idx = 1 THEN ' which won't work
'do somethin'
ENDIF
NEXT
An array of bits was another idea, but the compiler didn't like it.
Kinda like mybyte.LowBit(idx)) for the BS2 code.
Thanks!
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
"You're braver than you believe, stronger than you seem, and smarter than you think" Christopher Robin to Pooh
·
Ah yes, being tricky with bytes! I was thinking that there were some functions using or accessing bits like in PBASIC other than mybyte.1.
many thanks!
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
"You're braver than you believe, stronger than you seem, and smarter than you think" Christopher Robin to Pooh
·