I wanted to ask in assembly of pic - the difference between EQU and # define.
EQU I understood but confusion in # define as the following line in book says...
" A #define on the other hand tells the assembler to substitute two values where it finds a certain word e.g. #define led portb.4
Wherever the assembler finds the word led, it substitutes 6.4 (or portb.4) in it's place. "
Can anyone make me understand above statement...
Main thing i understood that # define is used as generic - that we can make changes only at one part of program and all the program the values shall be changed automatically...
Anywhere mpasm finds the word 'led' it will substitute the string 'portb.4'
The part about '6.2' is simply because somwhere else 'portb' has already been set (probably in the procesor INC file) using portb EQU 6 - Why six? Because 6 is the address of portb in the data memory area.
Hi,
General purpose registers are used for storing variables as well. So basically they are the same. That equate directive is for us to differentiate the registers easier, instead of the memory location, we can equate the name.
If you write your own self contain register programs without include file for different PICs you will understand this.You need to equal the SFR as well. If you call the include file no need equal.But need to equal the other GPR's or use cblock.
It doesn't need to 'know', it's simply a text substitution (both equ and define), the assembler first runs through the code and replaces all occurances of ' C ' with ' 0 ' as you told it to - there's no such thing as bits or bytes, just ASCII text.
People seem to find equ and define difficult to understand?, but when you realise it's just a simple text substitution it becomes easy - think 'search and replace' from your word processor.