Shop OBEX P1 Docs P2 Docs Learn Events
Finding things — Parallax Forums

Finding things

g3cwig3cwi Posts: 262
edited 2012-02-12 00:37 in Propeller 1
This evening I had to split a long into bytes. I started off on a scheme to do this but then thought to check around on the forum. A perfect answer was there. Snippet folows:
Testhex :=  $D605db76 '
     
            'The next code splits the long into the required bytes

            Reg_09_Byte := byte[@Testhex][3] 'splits off d6
            Reg_10_Byte := byte[@Testhex][2] 'splits off 05
            Reg_11_Byte := byte[@Testhex][1] 'splits off db
            Reg_12_Byte := byte[@Testhex][0] 'splits off 76

Where is great stuff like that documented or is searching around here the only way to find such gems?

I must say that I'm getting to like this stuff. Just yesterday programming an Si570 seemed like it would be all but beyond me - but I now have a fully working test system zooming about the bands!

Cheers

Richard

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2012-02-11 12:59
    Page 51 of the propeller manual:

    BYTE [BaseAddress] [Offset]

    The propeller manual is really good, but I guess it's sometimes hard to remember these kind of thing from reading it once ... or twice ...
    But here in the forum you are also welcome to ask such easy questions. At least you will get a pointer to where to find the needed information.
  • JonnyMacJonnyMac Posts: 9,197
    edited 2012-02-11 13:00
    You can also do this:
    Reg_09_Byte := TestHex.byte[3]
    


    By using this format you can use a variable index to retrieve a byte.
  • g3cwig3cwi Posts: 262
    edited 2012-02-12 00:37
    Thanks, I had read the manual but it seems I have an old version. Also I did not actually grasp the meaning of the examples just be reading them. I tend to learn by doing rather than just reading.

    Thanks too Jonny. I will try that.

    Cheers

    Richard
Sign In or Register to comment.