SX/B -- Arrays and Bit-Index

PJ AllenPJ Allen Banned
Regarding arrays and bit indexing:

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

Can't the·bitIndex number be a VARiable?

  FOR [color=red]X[/color] = 0 TO 7
    iso_bit = xmt_string(0).[color=red]X
[/color]    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.

  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
Tagged:

Comments

  • 3 Comments sorted by Votes Date Added
  • edited December 2006 Posts: 0Vote Up0Vote Down
    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
    logo.png?503
    Esterline Research & Design
    thitt@esterlineresearch.com

    We offer consulting on the following areas of expertise:
    Frequency Control - Micro-Controller/Processor Projects
    Test and Automation - General Programming and Coding
    Circuit Design - Board Layouts
  • edited December 2006 Posts: 0Vote Up0Vote Down
    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.

    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
    
    Jon McPhalen<div>Burbank, CA</div>
Sign In or Register to comment.