At first download MpLab on the botom of next page.
It is Integrated Development Environment (IDE). In simple words: software tool for writing and debugging programs for Pic MCU.

MPLAB Integrated Development Environment (IDE) is free development tool for writing program code for Michrochip MCU in assembler language.. It’s simple for use and it includes  debugging.And it also ofers upgrade  for “c” language with limited code size and MCU simulator. In simple word  Mp Lab compiles over code into hey file.


Lets  go to writing of  code . At first you must create new project and save it to the specific folder by clicking on project> new.



After that you must click on view> project to see the project window and to add the working window for program writing..


It is the project source file made by notepad text editor. File must have .asm file extension name. Yes at first you create normal Notepad document and then you change file name to asm.This one has only the configurations bits for my MCu. It could be blank But in this way i made my template of configuration bits.

Once it is inserted into MpLab IDE then we continue to write  program in it.


In this way you will make your work surface. As i have mentioned before. With it you have basis for further  program writing and from it then hex document will be  created.

I have to comment that this was my way of working and i  do not  know other way, but i believe that other ways of proceeding exist. Ok, I’m saying it for third time: in the same page i have then continued wit program writing which i have
equip it with program comments. Here i will write just some specifications  for program understanding  and syntax illustration of assembler language.

First line of a code in picture below is the last line of one picture before. here  you may see how i continue writing code from my template asm file which i have added to the project before as template. The variable definitions follows. Then i start with program.
Here is code to switch led on  on 7. pin of port d.

Here i will get some freedom to to express my opinion what implementation of program should be.  From my point of view it is serial jumping between memory cells and changing it’s content in base of specific needs. Now  i may conclude this explanation with compiling of program. It is executed by clicking on Build all icon.



12-bit PIC instruction set
Mnemonic Description
NOP No operation
OPTION Load OPTION register with contents of W
SLEEP Go into standby mode
CLRWDT Reset watchdog timer
TRIS f Move W to port control register (f=1..3)
MOVWF f Move W to f
CLRW Clear W to 0 (a.k.a CLR x,W)
CLRF f Clear f to 0 (a.k.a. CLR f,F)
SUBWF f,d Subtract W from f (d = f − W)
DECF f,d Decrement f (d = f − 1)
IORWF f,d Inclusive OR W with F (d = f OR W)
ANDWF f,d AND W with F (d = f AND W)
XORWF f,d Exclusive OR W with F (d = f XOR W)
ADDWF f,d Add W with F (d = f + W)
MOVF f,d Move F (d = f)
COMF f,d Complement f (d = NOT f)
INCF f,d Increment f (d = f + 1)
DECFSZ f,d Decrement f (d = f − 1) and skip if zero
RRF f,d Rotate right F (rotate right through carry)
RLF f,d Rotate left F (rotate left through carry)
SWAPF f,d Swap 4-bit halves of f (d = f<<4 | f>>4)
INCFSZ f,d Increment f (d = f + 1) and skip if zero
BCF f,b Bit clear f (Clear bit b of f)
BSF f,b Bit set f (Set bit b of f)
BTFSC f,b Bit test f, skip if clear (Test bit b of f)
BTFSS f,b Bit test f, skip if set (Test bit b of f)
RETLW k Set W to k and return
CALL k Save return address, load PC with k
GOTO k Jump to address k (9 bits!)
MOVLW k Move literal to W (W = k)
IORLW k Inclusive or literal with W (W = k OR W)
ANDLW k AND literal with W (W = k AND W)
XORLW k Exclusive or literal with W (W = k XOR W)


Leave a Reply

Google Analytics Stats

generated by GADWP