Shop OBEX P1 Docs P2 Docs Learn Events
GetBit Compile Problem — Parallax Forums

GetBit Compile Problem

RS_JimRS_Jim Posts: 1,771
edited 2009-07-29 13:32 in General Discussion
@Bean,
I have the following piece of code that does not want to compile:

Flags VAR Byte
AdoneX Var Flags.5

DO
tmpw1 = $FFFF
·GetBit Flags,5 ,__param5 'line wont compile
·IF __param5 <> 0 THEN
··AccResult = ACC_RESULT
··ATIme = __wparam34
··tmpW1 = DACC
··TX_BYTE tmpW1_MSB
··TX_BYTE tmpW1_LSB
··TX_STR CRLF
·ENDIF
Loop
I get invalid parameter· __param5
If I change it to GetBit Flags, AdoneX, __Param5 I get same error
if I change it to GetBit Flags,.5,__param5 I get invalid Number of Params
what is wrong with my GETBIT Request?
If i comment out the Getbit, the program compiles/assembles no problem.

Comments

  • BeanBean Posts: 8,129
    edited 2009-07-26 14:16
    Jim,
    I guess I need to add to the documentation.

    The 3rd parameter must be a bit variable, and the 2nd parameter cannot be a constant. Because then you could just use __PARAM5.0 = flags.5.

    I would change your code to:

    PARAM5 = flags.5

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Does that byte of memory hold "A", 65, $41 or %01000001 ?
    Yes it does...


    ·
  • RS_JimRS_Jim Posts: 1,771
    edited 2009-07-26 14:46
    OK, that compiles correctly, Now I am not sure why I would not just use __param5.0 = Adonx if I needed it in Bit 0. I am just
    testing to determin if the flag has been set before preforming the next step so a 0/<>0 result is all I care about.
    Jim
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-07-26 17:32
    You can test a bit directly:

    IF flags.5 THEN
      ' code runs if flags.5 = 1
    ENDIF
    


    For zero you would do this:
    IF flags.5 = 0 THEN
      ' code 
    ENDIF
    
  • RS_JimRS_Jim Posts: 1,771
    edited 2009-07-27 17:42
    Great JonnyMac,
    so if a Have an alias for flags.5 then:

    IF adonex = 1 then
    'code
    ENDIF

    or
    IF adonex = 0 then
    'code
    ENDIF

    if this works I can do a great thing with my code,
    RS_JIM
  • JonnyMacJonnyMac Posts: 9,213
    edited 2009-07-27 21:57
    That syntax will work, I use it all the time. Just create the alias in your variables declarations.
  • RS_JimRS_Jim Posts: 1,771
    edited 2009-07-29 13:32
    Cool, The declaration is already done.
Sign In or Register to comment.