Never seen this before!!


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default Re: Never seen this before!!

    Quote Originally Posted by Megahertz View Post
    Code:
     
    movlw   -97
    addwf   TMR0
    I have never come across any negative number getting loaded into a variable.
    Is this the same as Loading 159-> (256-97=159) to Timer0 ?
    It sure is.

    You can look at the .LST file after you compile the program and find the line for "movlw -97". You will see that it will be something like:

    00009E 0E9F 00232 movlw -97

    00009E <-- Address of the the instruction

    0E9F <-- Actual instruction code

    If you look up the MOVLW code in the PIC datasheet, you will see the OP-CODE (most significant 8 bits of the 16 bit instruction) is $0E (%00001110). The literal is the 8 least significant bits, $9F in this case (which is 159).
    Last edited by SteveB; - 1st July 2012 at 23:08.

  2. #2
    Join Date
    Nov 2009
    Location
    London
    Posts
    251


    Did you find this post helpful? Yes | No

    Default Re: Never seen this before!!

    Much appreciated your in-depth answer. Thanks Steve

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