1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Problem saving variables?

Discussion in 'Microcontrollers' started by Rod Harty, Aug 4, 2017.

  1. Rod Harty

    Rod Harty New Member

    Joined:
    Aug 4, 2017
    Messages:
    2
    Likes:
    0
    I'm using a Mplab IDE v8.92 compiler. I can assign a variable to a value:
    movlw b'00000111'
    movwf var1 ;initialize var1
    the watch box shows that the memory position (in this case, 0x20) holds the correct value.
    However, when I retrieve the value;
    clrw
    movlw var1
    the work register shows the memory position, not the value contained.

    Ideas?
     
  2. jpanhalt

    jpanhalt Well-Known Member Most Helpful Member

    Joined:
    Jun 21, 2006
    Messages:
    5,886
    Likes:
    500
    Location:
    Cleveland, OH, USA
    If you show your whole code it will help. One of the "gottchas" of Assembly is the movlw instruction. It will return the register location, which BTW is very useful for setting up indirect addressing. Try, "movf register,w"

    John
     
  3. Rod Harty

    Rod Harty New Member

    Joined:
    Aug 4, 2017
    Messages:
    2
    Likes:
    0
    That works, Thank you,
     

Share This Page