ShiftIn to array of bits using EXT modifier?


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,580

    Default ShiftIn to array of bits using EXT modifier?

    Hi,
    I have an array of bits (MB_Inputs) to which I want to shift in data from an external device. After trying a couple of different things without luck I came to think of Darrels writeup on the EXT modifier and thought I'd give that a try:
    Code:
    DataIn VAR WORD EXT
    @DataIn = _MB_Inputs
    and then later on
    Code:
    ShiftIn PortB.0, PortB.1, 0, [DataIn \16]
    This actually seems to work but when compiling I get an assmebler error 108, Illegal character (,) on line 1532 in the ASM file, that particular line is:
    Code:
    DataIn = _MB_Inputs
    Questions:
    1) Any idea why I get the error? I hope it's not the underscore "inside" my variable name...
    2) Since it, despite the error message, seems to work on the target should I just disregard the error? (Hard to do but I guess I can be convinced)
    3) Any other way of shifting data directly into an array of bits using ShiftIn?

    I know this may look weird as I could just as well have used a WORD to begin with but it is what it is.

    Thanks!
    /Henrik.

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: ShiftIn to array of bits using EXT modifier?

    Hi Henrik,

    BYTE and WORD variables only have one value that is a pointer to an address in RAM.

    But BIT's and BIT arrays have two parameters ... the address, and a pointer to the bit in that address, because PBP can combine BIT arrays into single bytes if they are small enough. This makes it difficult to locate the beginning of the array since MyBitArray(0) may start at bit5 of the byte it's located in. These are located in PB01 type variables that PBP creates.

    Fortunately, if the BIT array is more than 8 bits, PBP will will create a PBA01 type variable and the first bit will always start at bit0.

    In ASM, a BIT array is aliased like this ...
    #define _MB_Inputs PBA01,0

    You have to strip off the ,0 to be able to assign it to an EXT var.
    Code:
    MB_Inputs  VAR BIT[16]
    DataIn     VAR WORD EXT
    
    @ #define Reg(Areg,Abit) Areg
    @DataIn = Reg(_MB_Inputs)
    The #define creates a "function" that only returns the register part of the BIT alias.
    So DataIn will be assigned to PBA01 without the ,0.

    HTH,

    .
    Last edited by Darrel Taylor; - 11th March 2011 at 15:44.
    DT

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,580


    Did you find this post helpful? Yes | No

    Default Re: ShiftIn to array of bits using EXT modifier?

    Thanks Darrel!
    Looks like it's working :-)
    So, as long as the array of bits is longer than 8 this method is safe to use, nice to know!

    /Henrik.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

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