MPASM Help


Results 1 to 8 of 8

Thread: MPASM Help

Threaded View

  1. #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

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