Re: PIC EQU section.
- From: "ian field" <dai.ode@xxxxxxxxxxxx>
- Date: Thu, 21 Feb 2008 19:34:55 GMT
"Richard Seriani" <richard_s633@xxxxxxx> wrote in message
news:e5kvj.2664$yk5.2209@xxxxxxxxxxxxxxx
"ian field" <dai.ode@xxxxxxxxxxxx> wrote in message
news:zMjvj.4836$d62.2643@xxxxxxxxxxxxxxxxxxxxxxx
Ian,
"me" <me@xxxxxxxx> wrote in message
news:Xns9A4B7EB195C8Cmeherenet@xxxxxxxxxxxxxx
"ian field" <dai.ode@xxxxxxxxxxxx> wrote in
news:bTivj.2312$g81.1350@xxxxxxxxxxxxxxxxxxxx:
It is the same as;
"Michael" <news@xxxxxxxxxxx> wrote in message
news:47bdb89f$0$1092$4c368faf@xxxxxxxxxxxxxxxxx
ian field wrote:
In a sample fragment of code (EQU section) of a program example fromIt doesn't. Essentially it just wants to convert its operands to
the book PIC in Practice:
TMR0 EQU 1 ;TMR0 is FILE 1.
PORTA EQU 5 ;PORTA is FILE 5.
PORTB EQU 6 ;PORTB is FILE 6.
STATUS EQU 3 ;STATUS is FILE3.
ZEROBIT EQU 2 ;ZEROBIT is Bit 2.
COUNT EQU 0CH ;USER RAM LOCATION.
EEADR EQU 9 ;EEPROM address register
EEDATA EQU 8 ;EEPROM data register
EECON1 EQU 8 ;EEPROM control register1
EECON2 EQU 9 ;EEPROM control register2
RD EQU 0 ;read bit in EECON1
WR EQU 1 ;Write bit in EECON1
WREN EQU 2 ;Write enable bit in EECON1
How does the assembler tell the difference between a file and a bit?
The lines starting with ZEROBIT and WREN do not seem to have
anything to distinguish them from file EQUs.
TIA.
numbers. You could substitute WR whenever you wanted to use bit 1 of
file register 1 or the value 1, the assembler wouldn't care.
However, the human viewing the program would probably be very
confused :-).
Well it worked - I am confused!
Perhaps my question should have been - is the example wrong/badly
written and if so how do I do it correctly?
x=7
y=2
It has the benefit of making changes easy and giving an easier to
decipher source code. By using WR or RD you can tell what the code is
doing instead of 0 or 1...
Yes - I know what the EQU section does, but how does the assembler know
"ZEROBIT EQU 2 ;Zerobit is bit 2" means a bit and not a file -
especially when nothing specifies which file it means bit 2 of?
In the case of the equates, all the program is saying is that there is a
variable named ZEROBIT and you have assigned the value of 2 to it. The
comment tells you a little about what the programmer intends to use it for
(bit 2 of some register is going to be used as the zero bit).
The WREN variable is assigned a value of 2 and the programmer uses it to
describe a particular bit (write enable) in the EECON1 register. If you
look at the datasheet for the PIC being used, bit 2 of the EECON1 register
is probably called WREN and is the EEPROM Write Control bit.
Somewhere in the rest of the program, you'll find how the programmer used
thes equates.
A lot of what I see in the equates you provided looks like stuff that
could also be in an include file. Something like
#include "p16f88.inc"
sometimes covers all these type of assignments.
The author of the book this came from has opted to write his own .inc files
to replace the ones supplied by Microchip, except they have an .asm
extension and each is used as a template to which the program code is added
for a variety of programming examples.
From what I'd read, the label names were completely arbitrary - "ZEROBIT"could be called whatever you want as long as consistency was maintained
throughout - if I'm wrong about that it probably answers my question.
.
- Follow-Ups:
- Re: PIC EQU section.
- From: Peter Bennett
- Re: PIC EQU section.
- References:
- PIC EQU section.
- From: ian field
- Re: PIC EQU section.
- From: Michael
- Re: PIC EQU section.
- From: ian field
- Re: PIC EQU section.
- From: me
- Re: PIC EQU section.
- From: ian field
- Re: PIC EQU section.
- From: Richard Seriani
- PIC EQU section.
- Prev by Date: Anyone Needing a 68HC11 Based Board?
- Next by Date: Re: PIC EQU section.
- Previous by thread: Re: PIC EQU section.
- Next by thread: Re: PIC EQU section.
- Index(es):
Relevant Pages
|