Searching \ for '[pic]: beginning assembly question' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/microchip/begin.htm?key=pic
Search entire site for: 'beginning assembly question'.

Exact match. Not showing close matches.
PICList Thread
'[pic]: beginning assembly question'
2001\04\15@211324 by rad0

picon face
what are these equate statements doing?

Is this assigning the var labels to positions in memory or
setting aside memory space, or what?

thanks in advance


; VARIABLE DECLARATION

TEMPW             EQU      0x20

TEMPS              EQU      0x21

REGA                EQU      TEMPS + 1

REGB                EQU      REGA + 1

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body


2001\04\15@214047 by Jeff Johnson

picon face
> what are these equate statements doing?
>
> Is this assigning the var labels to positions in
> memory or
> setting aside memory space, or what?
>
> ; VARIABLE DECLARATION
>
> TEMPW             EQU      0x20

Yes. This is assigning a label to an address in
memory. This allows you to write your code as

    movf     TEMPW,W     ;load W with contents of
address 20

    instead of the more cumbersome

    movf     0x20,W

or assigning a value to a label

    movlw     TEMPW     ;load W register with value
assigned to TEMPW

such that whenever the assembler sees the label, it
substitutes the equated value at build time.

Jeff Johnson
http://home.dialix.com/~u2263/index.htm

__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservKILLspamspam@spam@mitvma.mit.edu with SET PICList DIGEST in the body


2001\04\15@220438 by rad0

picon face
Thanks very much,

I forgot to ask, is it assumed to 1 byte in memory, or is this
something for each processor?


for
0x20
and
0x21

is 0x21 1 byyte away from 0x20 ?


{Original Message removed}

2001\04\15@221239 by michael brown

flavicon
face
They are assigning the variables TEMPW and TEMPS to specific RAM addresses
(that they apparently know or assume are available for their specific
usage). The variables REGA and REGB are being assigned to addresses relative
to the first two variables.  There are other (more elegant)  ways to assign
variables to memory locations, that are probably more convenient in terms of
porting the code to another processor or performing code maintenance (look
into the CBLOCK pseudo-op).  My terminology on these items may not be the
most appropriate as I am also new to the PIC thing.  I hope I have helped
you in some way.  Have fun.

Michael Brown
Instant Net Solutions
http://www.KillerPCs.net

{Original Message removed}

2001\04\15@221859 by rad0

picon face
wait a minute,

all registers are 1 byte wide for all pics, true?



----- Original Message -----
From: "rad0" <rden25spamKILLspamMINDSPRING.COM>
To: <.....PICLISTKILLspamspam.....MITVMA.MIT.EDU>
Sent: 15 April, 2001 21:03
Subject: Re: [pic]: beginning assembly question


{Quote hidden}

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email RemoveMElistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body


2001\04\15@223146 by Douglas Wood

picon face
Look in the processor's data sheet. (Yes, they're all one byte wide.)

Douglas Wood
Software Engineer
spamBeGonedbwoodspamBeGonespamkc.rr.com

Home of the EPICIS Development System for the PIC and SX
http://epicis.piclist.com

{Original Message removed}

2001\04\15@223600 by Douglas Wood

picon face
Strictly speaking, each EQU assigns a value to its associated label. For
example, TEMPW is not a memory location, but an assembler constant defined
as having the value 0x20. It just so happens that it also represents a
physcial memory address.

To specify a label as being a physcial memory address (instead of simply a
constant) use RES.

Douglas Wood
Software Engineer
TakeThisOuTdbwoodEraseMEspamspam_OUTkc.rr.com

Home of the EPICIS Development System for the PIC and SX
http://epicis.piclist.com

> {Original Message removed}

2001\04\15@223612 by myke predko

flavicon
face
Strictly speaking all you are doing is assigning the label "TEMPW" to the
number 0x020 (32) (and so on).  What you use them for (memory address,
location in register space, number of coffee beans in a decagram or
whatever) is totally up to you.  The assembler couldn't care less as long as
it is within the range required for the destination.

This is a *really* subtle point and one that is important to remember
because I continually see new PICmicro programmers get messed up on it.  The
reason why it is confusing is that most new programmers assume the assembler
is a lot smarter than what it is.

I'm being pedantic because of your follow up question ("I forgot to ask, is
it assumed to 1 byte in memory, or is this something for each processor?").
The only thing assumed is that each label is assigned to a constant.


The four labels below could be declared using:

CBLOCK 0x020
TEMPW
TEMPS
REGA
REGB
ENDC

or

ORG 0x020
TEMPW
ORG 0x021
TEMPS
ORG 0x022
REGA
ORG 0x023
REGB

or using the equate symbols that you have specified below.  In any of the
cases, you can use the labels as constants, register addresses or program
memory addresses.


To keep the usage of the labels for different purpose separate, I use the
four conventions:

1.  For variable registers, I use the CBLOCK directive.  Note that with the
CBLOCK statement, you have the option of specifying how many the counter is
incremented by (the default is one) before the next label's value is
assigned.
2.  For program memory address, I define the labels in the source code as I
show above.
3.  For numeric constants, I use the "EQU" directive as you have done.
4.  For variables within conditionally assembled code, I use the "define"
directive.  This allows a great deal of flexibility in programming, but it
is often not for the faint of heart.

myke
{Original Message removed}

2001\04\15@224227 by rad0

picon face
OK, that clears it up, this reply and the ones before, thanks all.

I was flipping around the data sheet and I see that all the internal
registers are bytes.  Thanks



{Original Message removed}

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