Table of Contents
what are the assembler directives in PIC?
what are the assembler directives in PIC? Assembler directives are the instructions used by the compiler or assembler while assembling a source program .As from the name we come to know the these basically gives direction to the assembler so, these are the commands that controls the assembler .Assembler directives are the commands given to the assembler not to the processor because processor can only understand the machine language i.e. 0and1
We know that the processor can only understand machine language . We have already given commands to the assembler using assembler directives so, the next step compiler perform is, it changes the assembler directives to machine language and passes the command to the processor and the processor perform the work according to the command given by the compiler.
e.g. MOWF this is a directive which actually moves the value of WREG register into file register so, the assembler converts it into machine language and sends it to processor and the performs it.
Importance of Assembler:
As the machine language is too much hard to program and understand therefore compiler is made which is programmed in such a way by experts that it automatically changes the assembly language(commands are in the form of mnemonics rather than machine co 0,1) into machine language and passes the command to the processor.
Different assembler Directives of pic microcontroller:
There are many types of assembly directive I am going to explain each of them individually.
The EQU instruction assigns complete or searchable values to symbols. Use it to:
- It provides single absolute values to the
- Assign the values of antecedently outlined symbols or expressions to new symbols, therefore holding you employ totally different method for various functions.
- Compute expressions whose values ar unknown at secret writing time or troublesome to calculate. the worth of the expressions is then assigned to an emblem.
- Assign length and sort attributes to symbols, either implicitly or expressly.
- Assign program sort and program sort values to symbols.
EQU additionally assigns attributes. It takes the worth, relocation, and length attributes of the quantity and assigns them to the name field image, and sets the number and scale attributes to zero. the kind attributes of associate degree absolute expression is usually ‘U’, and its length attribute is usually one (unless the second and third operands ar mere.
When there’s an emblem naming a fancy relocatable expression, or a fancy relocatable expression is eventually “reduced” to associate degree absolute or just relocatable expression, the primary image is employed for attribute assignment.
The program sort is usually null, and therefore the program sort is usually null, except once the acceptable quantity is mere.
This is a directive the purpose of which is also same to EQU like it defines a constant value or fixed address but the difference is that the value assigned by set directive can be reassigned letter.
The origin directive tells the computer program wherever to load directions and information into memory. It changes the program counter to the worth fixed by the expression within the quantity field. sequent statements square measure assembled into memory locations beginning with the new program/location counter price. If no ORG directive is encountered in an exceedingly computer program, the program counter is initialized to zero.
This is a very important directive this tells the assembler the end of a program or a source file. This indicates the assembler that this is the last line and the assembler ignores all the codes after end directive .The end directive is always at the last of source file
List directive is basically different to the pic assembler it not like END and ORG which the assembler uses it stipulates to a compiler the specific chip of which the program should be assembled.
LIST P=18F550 ; we are using pic 18 here
If we consider the above example of pic the list directive directs the assembler that we are using PIC18F550 microcontroller
In the C language, the #include directive directs the compiler to insert the contents of another file into source code text file at the purpose wherever the #include directive is det. embody directives area unit usually wont to embody the C header files for C functions that area unit command outside of the present supply file.
The CONFIG directive tells the compiler the configuration bits for the targeted PIC chip.it is necessary to use the proper CONFIG directive, as a result of incorrect use might create the chip unusable . The configuration bits area unit scan throughout power-up of the PIC device and area unit hold on at location 300000H.Microchip has outlined the CONFIG directive symbols to ease the configuration. These symbols area unit situated within the .INC file for the device that’s being employed
We can use the number directive to point whether or not the enumeration system is hexadecimal representation system or decimal. The default is hex if we tend to don’t use the number directives. If we tend to use “radix dec” , the default illustration can modification the decimal and any unformatted variety are understood as decimal instead of hex.