Author Topic: How to see the value of W register and other general purpose registers in MPLAB  (Read 634 times)

0 Members and 1 Guest are viewing this topic.

Offline khatusTopic starter

  • Regular Contributor
  • *
  • Posts: 146
  • Country: gl
I wanted to know the content of W register and content of the adress location 12H in pic 16f84 micrcontroller.
I have write this simple code

Code: [Select]
RES_VECT  CODE    0x0000         
GOTO    START                 
MAIN_PROG CODE                     
START
MAIN
MOVLW b'11';// w contains 3
MOVWF 12H ; // 12H contains 3
MOVLW b'100'; // w contains 4
ADDWF 12H, W ; // w contains 7
ADDWF 12H, W ; // w contains 10
ADDWF 12H, W;  // w contains 13
ADDWF 12H, W; // w contains 16
END

The code was compiled successfully. Here  is a picture of it




But the problem is when I open the SFR View window (Window>PIC memory views>SFRs) to see the content of the w register of the target device for the current project.



It shows WREG content is 19. Even if I do not write the code it shows WREG content is 19. That means The code I wrote is not affecting the ‘w’ registers at all.
since the result will be 16 . My question is how I can view my correct answer in MPLAB ide?






 

Online DavidAlfa

  • Super Contributor
  • ***
  • Posts: 5914
  • Country: es
You have to run the simulator and then step the code.




Proteus can also simulate PIC, but not sure if the demo does.

For learning purposes, "Proteus Professional v8.16 SP3 Build 36097" can be easily found in Google.
« Last Edit: December 23, 2023, 10:11:22 pm by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 
The following users thanked this post: newtekuser

Offline 8goran8

  • Contributor
  • Posts: 29
  • Country: cs
Everything is fine with your example. You have to start the debugger and go through the code step by step.
 

Offline khatusTopic starter

  • Regular Contributor
  • *
  • Posts: 146
  • Country: gl
Hello, i wanted to see,
1) your full code
2) Your full window screenshot
3) your mplab version
IS it possible for you to post screenshots step by step? Because I am new in this field?OR make  a video and send me the link?
« Last Edit: December 24, 2023, 03:56:41 am by khatus »
 

Online DavidAlfa

  • Super Contributor
  • ***
  • Posts: 5914
  • Country: es
Just set it for simulation, takes 30 seconds, check the video!
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline jpanhalt

  • Super Contributor
  • ***
  • Posts: 3479
  • Country: us
It runs and does exactly as written, as others have also said.
Device: PIC16F84
IDE: MPLAB 8.92
MPLAB SIM
MPASM v.5.49

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf