+ Reply to Thread
Results 1 to 3 of 3

Thread: SX/B -- Arrays and Bit-Index

  1. #1
    PJ Allen's Avatar
    Location
    Outer Darkness! Charon-Quaoar-Sedna Circuit
    Posts
    4,980
    Blog Entries
    1

    Default SX/B -- Arrays and Bit-Index

    Regarding arrays and bit indexing:

    Symbol VAR Byte { (Size) } {.bitIndex}

    Can't the·bitIndex number be a VARiable?

    Code:
      FOR X = 0 TO 7
        iso_bit = xmt_string(0).X
        RA.0 = iso_bit
        PAUSEUS duration
        NEXT

    ·I'm trying to bit-bang out a byte (on RA.0) without using >>.

    ·** Post Edit **· No Replies.· Dang.· Moving forward with SHR (a.k.a. >>.)· Transmitting data 1200, 8-E-1.· So far, so good; no parity, frame or block errors.· Huzzah.

    Code:
      FOR parse = 0 TO 7       
        iso = xmt_str & $01     'result = $00 or $01
        RA.0 = iso.0            'output bit 0 of iso
        parbit = parbit + iso   
        PAUSEUS 833.3
        xmt_str = xmt_str SHR 1 'Shift Right xmt_str
        NEXT                    'NEXT parse

    Post Edited (PJ Allen) : 12/17/2006 1:37:26 AM GMT
    Last edited by ForumTools; 10-02-2010 at 12:44 AM. Reason: Forum Migration

  2. #2

    Default

    PJ,
    No the bitIndex CANNOT be a variable. This is mainly due to the fact that the SX processor does not allow it in assembly either.


    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com
    Stuff I'm selling on ebay http://search.ebay.com/_W0QQsassZhittconsultingQQhtZ-1

    "USA Today has come out with a new survey - apparently, three out of every four people make up 75% of the population." - David Letterman
    Last edited by ForumTools; 10-02-2010 at 12:44 AM. Reason: Forum Migration

  3. #3

    Default

    I'm working on a "Life" program for the SX (using an 8x8 array of LEDs) and need to do bit indexing as well. Here's function that I have started with; it may be helpful to you.

    Code:
    BITVAL        FUNC    1, 2, 3
    
    . . .
    
    ' Use: value = BITVAL someVal, position
    ' -- "someVal" can be a byte or word
    
    BITVAL:
      IF __PARAMCNT = 2 THEN                        ' byte passed?
        tmpW1 = __PARAM1                            ' get byte value
        tmpB1 = __PARAM2                            ' get bit position 
      ELSE                                          ' word passed
        tmpW1 = __WPARAM12                          ' word was passed
        tmpB1 = __PARAM3                            ' get bit position
      ENDIF
      tmpB2 = 0                                     ' assume cleared
      IF tmpB1 >= 0 THEN                            ' position value legal?
        IF tmpB1 <= 15 THEN
          tmpW2 = 1 << tmpB1                        ' create bit mask
          tmpW2 = tmpW2 & tmpW1                     ' clear other bits
          IF tmpW2 > 0 THEN                         ' if not zero
            tmpB2 = 1                               '   bit was 1
          ENDIF
        ENDIF  
      ENDIF
      RETURN tmpB2
    Last edited by ForumTools; 10-02-2010 at 12:44 AM. Reason: Forum Migration

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts