Shop OBEX P1 Docs P2 Docs Learn Events
@ Terry Manipulating Constants — Parallax Forums

@ Terry Manipulating Constants

pjvpjv Posts: 1,903
edited 2009-02-24 16:21 in General Discussion
Hello Terry;

In using SX/B I frequently·need to manipulate some constants at compile time. They are static once the compilation is done.

So my need is to call a function or sub with·a constant, modified by operators as required. Unfortunately the compiler throws an "invalid number of parameters" error when it encounters the constant's manipulation operators.

I know there are work-arounds, but is it possible in the case of constants, to have the compliler pass-on the desired code to the assembler? The assembler is happy to deal with them and calculate the intended value.

Obviously the complier would not want to deal with figuring out what to do with variables subjected to manipulation, but I wondered if it could manage with constants???

Thanks for your consideration.

Cheers,

Peter (pjv)
·

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2009-02-22 22:38
    pjv,

    Can you give an example?

    regards peter
  • pjvpjv Posts: 1,903
    edited 2009-02-22 22:59
    Sure;

    Sub ReadFram takes 4 Parameters, variables or constants:

    ReadFram (Addr << 2), Page, Dest, Qty

    Where for a particular instance, Addr and Page are constants at compile time, and in another instance, all may be variables.

    Cheers,

    Peter (pjv)
  • John CoutureJohn Couture Posts: 370
    edited 2009-02-24 00:05
    (grin) And here I have been thinking for all this time that PJV and Peter Verkaik are the same guy! Oops!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John J. Couture

    San Diego Miramar College
  • BeanBean Posts: 8,129
    edited 2009-02-24 00:59
    pjv,
    No, the only way would be to declare another constant.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There is a fine line between arrogance and confidence. Make sure you don't cross it...

    ·
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2009-02-24 01:50
    pjv,
    Another way to handle this is by loading __param1 yourself,
    __param1 = addr << 2
    ReadFram __param1, Page, Dest, Qty

    sxb will not load __param1 (because __param1 parameter is at the right position.)
    I use this construct frequently in my libraries.

    regards peter
  • pjvpjv Posts: 1,903
    edited 2009-02-24 16:21
    Thanks All.

    Cheers,

    Peter (pjv)
Sign In or Register to comment.