Shop OBEX P1 Docs P2 Docs Learn Events
Need help moving 2 1-byte variables into a Long — Parallax Forums

Need help moving 2 1-byte variables into a Long

SteelSteel Posts: 313
edited 2007-08-20 18:32 in Propeller 1
This code is not working for me:

VAR
·· Long·· X_VALUE
·· Byte·· Buffer[noparse][[/noparse]2]


PUB
·· Buffer[noparse][[/noparse]0] := $FF
·· Buffer[noparse][[/noparse]1] := $FF

· X_VALUE[noparse][[/noparse]15..8] := Buffer[noparse][[/noparse]0]
· Y_VALUE[noparse][[/noparse]7..0] := Buffer[noparse][[/noparse]1]


...I thought that since DIRA and OUTA are pin addressable, that variables would be to := ?

How do you concantenate 2 byte variables into 1 long variable?

Thanks
Shaun
·

Comments

  • MightorMightor Posts: 338
    edited 2007-08-20 17:05
    Steel said...
    This code is not working for me:
    .
    .
    How do you concantenate 2 byte variables into 1 long variable?

    Thanks

    Shaun
    A long is 4 bytes, err long. Did you mean to use a Word sized variable, they're two bytes big.
    For a word it would be something along the lines of
    varname.Byte[noparse][[/noparse] 0 ] = buffer[noparse][[/noparse] 0 ]
    varname.Byte[noparse][[/noparse] 1 ] = buffer[noparse][[/noparse] 1 ]
    
    



    Gr,
    Mightor

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    | To know recursion, you must first know recursion.
  • SteelSteel Posts: 313
    edited 2007-08-20 17:36
    Thanks, Mightor.

    The var is a long because I am using it in other places...but the same principle applies.

    Thank you!
  • deSilvadeSilva Posts: 2,967
    edited 2007-08-20 18:32
    Steel said...
    ...I thought that since DIRA and OUTA are pin addressable, that variables would be to := ?
    No. As SPIN does not really know of arrays, it cannot distinguish whether you use a straight variable or the start element of a vector. It is different with reserved names as OUTA, INA,....
    Steel said...
    How do you concantenate 2 byte variables into 1 long variable?
    Be careful as the Prop is a little-endian machine..
Sign In or Register to comment.