MPASM Help


Closed Thread
Results 1 to 8 of 8

Thread: MPASM Help

  1. #1
    Join Date
    Oct 2005
    Posts
    74

    Question MPASM Help

    This is all greek to me. MPASM is saying I have a "Aurgument out of range - Using LSB". Line 206 of Mac File.

    SUB?CBB macro Cin, Bin, Bout
    MOVE?BA Bin
    sublw Cin <------- Line 206
    MOVE?AB Bout
    endm

    I have not a clue to what any of this is or what is causing the warning error.
    18F4530 PBP 2.46 MPASM

    Any hints or clues? Never used MPASM before and it's got me all bent out of shape.
    Richard

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by rwskinner View Post
    This is all greek to me. MPASM is saying I have a "Aurgument out of range - Using LSB". Line 206 of Mac File.

    SUB?CBB macro Cin, Bin, Bout
    MOVE?BA Bin
    sublw Cin <------- Line 206
    MOVE?AB Bout
    endm
    I have not a clue to what any of this is or what is causing the warning error.
    18F4530 PBP 2.46 MPASM
    Any hints or clues? Never used MPASM before and it's got me all bent out of shape.
    Richard
    I'm fairly sure it means that you're using a word, and the function wants a byte, so it only uses the low byte.
    Figure out which line 'calls' this line in the assembly file and you should have your answer.

  3. #3
    Join Date
    Oct 2005
    Posts
    74


    Did you find this post helpful? Yes | No

    Default

    Thanks, this helped a lot.

    The offending code, which works fine is.....
    LRC = 256 - LRC

    LRC is defined as a byte, but I have to subtract LRC from $100
    I guess I could say....
    LRC = $FF - LRC
    LRC = LRC -1

    Would be the same thing..., unless there is a better way or I just need to ignore the error since we only need the 8 LSB anyway.

    Richard

  4. #4
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    Are you doing SNMP by any chance?
    Charles Linquist

  5. #5
    Join Date
    Oct 2005
    Posts
    74


    Did you find this post helpful? Yes | No

    Default

    No, Modbus ASCII LRC Calculation

  6. #6
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Assume LRC = 10.

    LRC = 256 - LRC. Which works out to LRC = 246, but returns a warning message.

    Now try this approach with LRC still = 10;

    LRC = $FF - LRC ' LRC = 255 - 10. Now LRC = 245
    LRC = LRC - 1. Now we have 245 - 1 which = 244. Oops! Not what we expected, although it
    looked darn good at 1st glance.

    Now try this, and see if you can figure out why it works & doesn't return the warning
    message;

    LRC = !256-LRC ' LRC = NOT 256 - LRC

    Here's a short test to verify it;
    Code:
    LRC VAR BYTE
    X VAR BYTE
    
    Main:
        FOR X = 0 TO 255
        LRC = X ' We'll work with LRC = 0 to 255 to prove it works
        HSEROUT ["256-",DEC X,"="]
        LRC = !256-LRC
        HSEROUT [DEC LRC,13,10]
        NEXT X
    Here:
        GOTO Here ' done    
        END
    Food for thought ehh....;o}

    A more efficient approach would be to just promote LRC to a word variable,
    and use the lower byte for your result, but this is pretty cool.
    Last edited by Bruce; - 19th February 2008 at 21:51. Reason: A better way
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    .....Now try this, and see if you can figure out why it works & doesn't return the warning message;
    That's pretty slick...
    I almost missed it and was about to reply back that you were wrong in this instance. Good thing I didn't. My foot goes in my mouth enough as it is...

  8. #8
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    It certainly wouldn't be the 1st time I was wrong, but it does work..;o}
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Similar Threads

  1. 16F914 and MPASM
    By jderson in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 7th February 2009, 03:21
  2. 12F675 MCLR directive MPASM
    By OLDSCHOOL in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 4th May 2008, 01:29
  3. MPASM 18F4550 getting started
    By BrianT in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 4th September 2007, 23:59
  4. 18F8722 and MPASM confusion!
    By Jackson in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 2nd April 2006, 01:24
  5. Converting to MPASM
    By btaylor in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 4th November 2005, 01:35

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