SX/B: Variable number of subroutine parameters
Today's question:
I have a need to pass a variable number of parameters to a subroutine. The valid data range for each parameter is 0x00 through 0xFF, so I can't use a "padding" parameter and maintain the ability to send four bytes (some commands are four bytes long).
I was happy to see there's a variable that contains the number of parameters passed to a subroutine -- but the SX/B compiler complains when I try and pass less than four parameters with "invalid number of paremeters".
Is there anyway to do what I want? There's no null in SX/B AFAIK?
Thanks!
-marc
I have a need to pass a variable number of parameters to a subroutine. The valid data range for each parameter is 0x00 through 0xFF, so I can't use a "padding" parameter and maintain the ability to send four bytes (some commands are four bytes long).
I was happy to see there's a variable that contains the number of parameters passed to a subroutine -- but the SX/B compiler complains when I try and pass less than four parameters with "invalid number of paremeters".
Is there anyway to do what I want? There's no null in SX/B AFAIK?
Thanks!
-marc
Comments
MySub SUB 0,4 ' zero is minimum number of parameter, 4 is maximum number of parameters
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
·
Thanks for the quick response! [noparse]:)[/noparse]
-marc
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
·
That was 'remembered'; but thanks for pointing it out.
Am I right in thinking you're 'responsible' for the SX/B compiler? If I may be so bold, as a design request, going to eight (8) passable parameters for a function/sub-routine would really be useful.
BTW...SX/B rocks! A very good progression for those of use used to Stamps. Passing of parameters, interrupts, better I/O access...
-marc
· Guilty...
· The 4 parameter were "designed-in" because some of the high-level commands need 4 bytes of tempory storage.
· To have 8 parameter bytes would decrease the variable space by 4 bytes. Not good.
· But you can pass an array name as a single byte parameter and access as many elements as you need. Using the __RAM() virtual array.
· Just ask if you want an example.
P.S. Thanks for the kind words about the compiler. I will forward them to Ken [noparse];)[/noparse]
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
·
An example of passing the array would be great! Thanks!
-marc
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