Accessing MultiByte Variables in Assembler


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2009
    Posts
    13

    Default Accessing MultiByte Variables in Assembler

    This may have been covered elsewhere, but I'm having trouble figuring out how to access the High and Low Bytes of 16-bit Words in Assembler. I know I can point the FSR register at the _Variable to get the Low byte, add one, and get the High byte, but I was wondering if there was an easier more straightforward way.

    Also, I'm using the PM assembler, and I'm wondering if there is an equivalent for banksel?

  2. #2
    Join Date
    Jul 2008
    Location
    TURKIYE-KONYA
    Posts
    51


    Did you find this post helpful? Yes | No

    Default

    Code:
    MYVAR      VAR WORD
    
    MYVAR_L   VAR MYVAR.lowbyte
    MYVAR_H   VAR MYVAR.highbyte
    
    
    ASM
    
    CLRF    _MYVAR_L
    CLRF    _MYVAR_H
    
    ENDASM
    YOU CAN USE THIS. I USE THIS METHODE WITH LONG VARIABLES. THERE IS NO PROBLEM.

  3. #3
    Join Date
    Aug 2009
    Posts
    13


    Did you find this post helpful? Yes | No

    Default Thanks!

    Thank you very much! I'm surprised I didn't think of that.
    Now comes the next question.
    Is there a "banksel" function equivalent in PM assembler?

  4. #4
    Join Date
    Jul 2008
    Location
    TURKIYE-KONYA
    Posts
    51


    Did you find this post helpful? Yes | No

    Default

    Code:
    Is there a "banksel" function equivalent in PM assembler?
    NO THERE ISNT ANY EQUIVALENT FUNCTION.

    I KNOW THAT , PIC BASIC PRO MAKES THE BANKSEL FUNCTION ITSELF.

  5. #5
    Join Date
    Aug 2009
    Posts
    13


    Did you find this post helpful? Yes | No

    Default Hmm....

    I'm trying to use inline Assembler, but I use multiple arrays which means I need to address multiple banks. How can I tell which bank a given array is stored in?
    Also, I'm not certain how you mean that banksel is produced by PM itself. I'm using 2.5, and it's choking on errors - all related to my attempts to use banksel.

    This may all be simplified if I just specify which bank I want each variable in.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by The Altruist
    I'm having trouble figuring out how to access the High and Low Bytes of 16-bit Words in Assembler.
    Code:
    MyWord  VAR WORD BANK0
    
    ASM
        movf     _MyWord,w      ; this gets the LowByte
        movwf    PORTB
    
        movf     _MyWord + 1,w  ; this gets the HighByte
        movwf    PORTC
    ENDASM
    You can use the CHK?RP macro to locate the bank for any variable.
    But if you're accessing arrays, it's probably better to use an FSR/INDF.
    <br>
    DT

Similar Threads

  1. WRITECODE stores wrong 14-bit word values in FlashMEM
    By BobPigford in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 26th June 2009, 04:35
  2. PIC assembler forum?
    By Lajko in forum Off Topic
    Replies: 1
    Last Post: - 29th September 2008, 05:34
  3. Assembler problem
    By om3bc in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 25th March 2008, 19:12
  4. Variables not appearing in Watch Window MPLabv7.3
    By jd76duke in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 16th June 2006, 14:36
  5. Problems with variables
    By egberttheone in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 15th December 2004, 18:37

Members who have read this thread : 1

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

Tags for this Thread

Posting Permissions

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