Searching \ for 'Use of EQU Statement' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/index.htm?key=use+equ+statement
Search entire site for: 'Use of EQU Statement'.

Truncated match.
PICList Thread
'Use of EQU Statement'
1998\07\21@215313 by Ron Stone

picon face
Hi -- I need clarification on the use of the EQU statement.  It appears
that it is used either to assign a constant to a symbol or to establish
an addresss for a register.  My question is how does the assembler know
when EQU is being used for one purpose versus the other?  Is there
something in the syntax of the statement that signals this?  Thanks for
the help.  Please respond direct.

Ron

1998\07\21@220808 by Ron Fial

flavicon
face
The EQU is an 'equate' statement, and all the assembler does when it sees such a
statement is make an entry in a table (the symbol table) with the symbol and it
s assigned value.  Nothing else happens until you use the symbol in a line of as
sembly code.  Even then, the symbol is not a 'register', but merely a symbol rep
resenting a 'number'  When the assember encounters the symbol in the line of cod
e, it just substitutes the value you assigned.  If that is a place where the add
ress of a register is specified, then the symbol 'is' an address register.  If t
hat is a place where a constant is specified for adding to the W register, then
the value of the symbol is the value used to make up the instruction.  Nothing p
revents you from adding together or multiplying two symbols to make a new 'value
'.  But remember that the assembler will do the arithmetic at assembly time to m
ake up the final instruction (there won't be any 'add' or 'multiply' in the PIC
runtime.

OK, then, the symbol has only one attribute, its numeric value.  The only useful
ness it has is to give you an (easy to remember) word to use instead of a (hard
to remember) number.

Somebody else if probably going to explain this a lot better, and even give exam
ples, so read on..

 Regards,
  Ron Fial

At 09:50 PM 7/21/98 -0700, you wrote:
>Hi -- I need clarification on the use of the EQU statement.  It appears
>that it is used either to assign a constant to a symbol or to establish
>an addresss for a register.  My question is how does the assembler know
>when EQU is being used for one purpose versus the other?  Is there
>something in the syntax of the statement that signals this?  Thanks for
>the help.  Please respond direct.
>
>Ron
>

1998\07\21@223312 by Bill Cornutt

flavicon
face
-----Original Message-----
From: Ron Stone <spam_OUTastoneTakeThisOuTspamEROLS.COM>
To: .....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU <PICLISTspamKILLspamMITVMA.MIT.EDU>
Date: Tuesday, July 21, 1998 6:53 PM
Subject: Use of EQU Statement


>
As one who doesn't know that much, I feel that I can answer your
question.

First, EQU is short for equate.

What it does is to assign (equate) a value to a label.

---- equatting a register ------

cntreg EQU 6

This will cause the assembler to use the hex,decimal,octal value
of 6 where ever the label cntreg occures.  Be careful when
using values with two digits as they may be hex, octal or decimal
unless you specify which one you want.  There may be an funny
little word in the assembler that sets the default radix (?).

While cntreg may be a register, all it is doing is to replace
the label cntreg with 6.


------ equatting a constant ----

And the lable could represent a constant.  As when you
load the W reg with a number

qqq equ 5

Then if you load the W reg with qqq you will be putting the
value 5 into it.


----- equatting a address -------

It is very useful to equate a label to a address.
The line

red    btsf   5,2

will set the label red to the address that the assembler assigned to
that instruction.

Sometimes you may want to assign a address to a label without
having an instruction associated with the label/line of code.
This is done by the line

red EQU *

The astritics means to take the address for the next assembler
instruction and assign it to the label (red in this case)

so

red EQU *
     btsf   5,2

is the same as

red btsf   5,2


Can you equate a equated label to another label?

red EQU 3
black EQU red+1

Don't know, try it and see how it assembles.

That may get you started in the right direction.

Bill C.   .....billKILLspamspam.....cornutt.com




>Hi -- I need clarification on the use of the EQU statement.  It appears
>that it is used either to assign a constant to a symbol or to establish
>an addresss for a register.  My question is how does the assembler know
>when EQU is being used for one purpose versus the other?  Is there
>something in the syntax of the statement that signals this?  Thanks for
>the help.  Please respond direct.
>
>Ron
>

1998\07\21@232822 by Darrel Johansen

picon face
This discussion shows why the EQU statement is so dangerous.  It
simply tells MPASM to substitute the number following the EQU
whenever it encounters the name before the EQU.

It does not assign storage, and simply confuses things and requires
one to sift through the code to find out how it is used.  In some
architectures, the "#' symbol is used before an operand to denote a
literal value, but in the PIC this is not required.  Therefore it is
up to the designer to lay out the code so that it can be easily read.

For this reason, it is advisable to use the CBLOCK directive to
allocate variable space when making non-relocatable code with
MPASM, and to use the RES directive when letting MPLINK to assign
RAM to user variables. Look at the .MAP file to see how RAM gets
used and adjust your CBLOCKS or your data sections accordingly.

You can use EQU to hard-code variable space, but you've got to keep
track of what space is assigned, size of variables, and which
routines can re-use that variable space.  MPASM and MPLINK have
better methods to do that for you now.

--
___________________________
|     Darrel Johansen     |
|     tempe,  arizona     |
|   EraseMEdarreljspam_OUTspamTakeThisOuTprimenet.com  |
|_________________________|

1998\07\22@100240 by lilel

flavicon
face
Watch out for EQU in watch windows.  The watch window will recognise
a variable:

  BUTTON1   EQU    6

  You can add BUTTON1 to a watch window

  But you cannot add   PORTA:BUTTON1 to a watch window. It will
always read 0.  You have to specify PORTA:6  explicitly.  Microchip
sez they will fix this in a future version.



>
> Can you equate a equated label to another label?
>
> red EQU 3
> black EQU red+1
>

If you use nested EQU's, you are a sheep thief.


-- Lawrence Lile

    "An Engineer is simply a machine for
     turning coffee into assembler code."

Download AutoCad blocks for electrical drafting at:
http://home1.gte.net/llile/index.htm

1998\07\22@125453 by Peter L. Peres

picon face
On Tue, 21 Jul 1998, Ron Stone wrote:

> Hi -- I need clarification on the use of the EQU statement.  It appears
> that it is used either to assign a constant to a symbol or to establish
> an addresss for a register.  My question is how does the assembler know
> when EQU is being used for one purpose versus the other?  Is there
> something in the syntax of the statement that signals this?  Thanks for
> the help.  Please respond direct.

An address for a register IS a constant on PICs.

Peter

1998\07\22@155340 by Steve Smith

picon face
Following the bit on equates I use the following to assign memory

Membase   EQU   0Ch ; bottom memory address
GP1           EQU   Membase +.1 ; next location ....

Also works fine are 1 line macros

#DEFINE BANK0   BCF     STATUS,RP0

#DEFINE BANK1   BSF     STATUS,RP0

Hope this helps Steve (well it works 4 me) .........

1998\07\22@193044 by Roberto Marchini

flavicon
face
At 19.06 21/07/98 -0700, you wrote:
>The EQU is an 'equate' statement, and all the assembler does when it sees
such a statement is make an entry in a table (the symbol table) with the
symbol and its assigned value.  Nothing else [...]
>
>  Regards,
>   Ron Fial
>

I can write

XYZ EQU 0x7F

and also

XYZ = 0x7F

What's the difference?


Is the aritmetic integer or floating?

Thanks for help

Roberto Marchini

More... (looser matching)
- Last day of these posts
- In 1998 , 1999 only
- Today
- New search...