Assembly Language inside PBP


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2007
    Location
    South-West of Australia. A small town called Denmark. 'Where the forest meets the sea.'
    Posts
    136

    Default Assembly Language inside PBP

    I'm using PBP with a PIC18F1220 in a weather station.
    The rain gauge - a tipping bucket - triggers an assembler interrupt routine that accumulates the number of bucket tips.

    the variable (in PBP) that holds the count is:

    Rain VAR WORD

    And the ASM interrupt routine includes the instruction:

    incf _Rain ; Increment Rain variable

    all works OK but the asm does not recognise the variable 'Rain' as a WORD and 'rolls over when it reaches 255.

    How do I get the asm interrupt routine to deal with 'Rain' as a WORD

    Thanks
    Bill Legge

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    947


    Did you find this post helpful? Yes | No

    Default

    You can try this.

    movlw 1
    addwf _Rain ; increment the LSB
    btfsc STATUS,C ; if overflow, increase MSB
    incf _Rain+1

  3. #3
    Join Date
    Nov 2007
    Location
    South-West of Australia. A small town called Denmark. 'Where the forest meets the sea.'
    Posts
    136


    Did you find this post helpful? Yes | No

    Default BYTE/WORD in Assembler

    Thanks Jerson - I will give it a go.

    I presume that PBP allocates two BYTES of memory to the WORD sized variable 'RAIN' and the assembler routine only deals with one of them?

    I guess I could create two BYTES to hold the RAIN data and increment the 'higher' BYTE if there is a carry from the 'lower' - Seems a bit cumbersome and I was looking for a neater/easier way.

    Regards Bill Legge

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Wink

    Quote Originally Posted by Bill Legge View Post

    Seems a bit cumbersome and I was looking for a neater/easier way.
    Hi, Bill

    As the 18F1220 is a 8 bits processor ... the neater/easier way is to use a 16 bits device !!!

    not obvious easier, eh ???

    NOW, The "DT Instant interrupts" might do the trick " neater " ( sic ) ... it's not raining as the "Niagara falls" , after all ...

    OR use one of the chip 16 Bits counters ... you have 3 aboard, after alll ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bill Legge View Post
    I guess I could create two BYTES to hold the RAIN data and increment the 'higher' BYTE if there is a carry from the 'lower' - Seems a bit cumbersome and I was looking for a neater/easier way.
    Simple addition or incrementing variables doesn't use the system registers.
    So it's ok to break out of ASM and do it with PBP.
    Code:
    Rain   VAR WORD
    
    ASM
    MyInt
        ;save context
        ;asm part here
        ENDASM
          Rain = Rain + 1
        ASM
        ;more asm here
        ;restore context
        retfie
    ENDASM
    DT

Similar Threads

  1. Replies: 2
    Last Post: - 8th February 2009, 05:10
  2. Assembly Language Conflict
    By NO2K in forum General
    Replies: 2
    Last Post: - 24th July 2007, 00:42
  3. Passing arrays PBP <-> Assembly
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th April 2006, 01:01
  4. Assembly Language + PBP
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 10th January 2006, 13:54
  5. Replies: 2
    Last Post: - 8th August 2004, 16:00

Members who have read this thread : 1

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