Sci.Electronics.Basics

on Electronics-Related.com

  Home  |  Books  |  Sci.Electronics.Design  |  Sci.Electronics.Basics  |  Resources  |  Contact  | 
Sign in
username:

password:

Remember Me

Not a member?
Search Sci.Electronics.Basics

Search Tips

Sci.Electronics.Basics -> PIC EQU section.

There are 28 messages in this thread.
You are currently looking at messages 20 to 28.






Author: ian field
Date: 12:31 22-02-08



"Eeyore" <rabbitsfriendsandrelations@hotmail.com> wrote in message
news:47BE090C.804A6D9B@hotmail.com...
>
>
> ian field wrote:
>
>> the PIC in Practice book and the datasheet
>> makes no mention of this that I can find, or for that matter the WREN
>> label
>> which is also EQU 2
>
> I assume it means a value of 0000010B. Calling that a 'bit' is highly
> misleading.
>
> That book sounds dodgy to me.
>
> Graham
>

I could be a bad workman and blame my tools, but there seem to be a few
omissions that seem to present irresolvable problems until how it works is
explained.



Author: ian field
Date: 12:38 22-02-08


"petrus bitbyter" <pieterkraltlaatditweg@enditookhccnet.nl> wrote in
message
news:47be2648$0$28180$e4fe514c@dreader22.news.xs4all.nl...
>
> "ian field" <dai.ode@ntlworld.com> schreef in bericht
> news:Pwivj.2311$g81.1768@newsfe3-gui.ntli.net...
>> In a sample fragment of code (EQU section) of a program example from 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.
>>
>
> Read my answer in ABSE.
>
> You'd better crosspost next time.
>
> petrus bitbyter
>

Thanks all - I got my brain out of the endless loop now.



Author: Bill Bowden
Date: 23:54 22-02-08

On Feb 21, 11:01=A0am, "Greg Neill" <gneill...@OVEsympatico.ca> wrote:
> "ian field" <dai....@ntlworld.com> wrote in message
>
> news:zMjvj.4836$d62.2643@newsfe6-gui.ntli.net
>
>
>
> > Yes - I know what the EQU section does, but how does the assembler
> > know "ZEROBIT =A0 =A0EQU =A0 =A02 ;Zerobit is bit 2" means a bit and
not=
a
> > file - especially when nothing specifies which file it means bit 2 of?
>
> It doesn't know anything about bits or files. =A0All it
> knows is that you have assigned the constant 2 to a
> symbol ZEROBIT. =A0It doesn't know or care what you
> subsequently do with that symbol.
>
> However... when it comes across that symbol in code
> that you write (code that generates instruction
> sequences), it will substitute the number 2 for the
> symbol in the context in which it is found. =A0It's up
> to you to use the symbol in the appropriate context.

So how does (COUNTER EQU 20h) differ from (ZEROBIT EQU 02h) ?
The first (COUNTER) is a file register located at address 20h and can
be loaded with some value. Why is ZEROBIT any different? Is it not a
file register located at address 02 without any value assigned?

-Bill

Author: John Larkin
Date: 00:01 23-02-08

On Thu, 21 Feb 2008 18:53:19 GMT, "ian field" <dai.ode@ntlworld.com>
wrote:

>
>"me" <me@here.net> wrote in message
>news:Xns9A4B7EB195C8Cmeherenet@38.119.97.3... /> >> "ian field" <dai.ode@ntlworld.com> wrote in
>> news:bTivj.2312$g81.1350@newsfe3-gui.ntli.net:
>>
>>>
>>>"Michael" <news@bigtoes.com> wrote in message
>>>news:47bdb89f$0$1092$4c368faf@roadrunner.com...
>>>> ian field wrote:
>>>>> In a sample fragment of code (EQU section) of a program example
from
>>>>> 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.
>>>> It doesn't. Essentially it just wants to convert its operands to
>>>> 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?
>>>
>>>
>>>
>> It is the same as;
>>
>> 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?
>

ZEROBIT doesn't mean a file or a bit. It means 2.

Whether it refers to a file, a bit, or a rom address depends on the
contexts it might be used it. Same as for "2"

John


Author: BobW
Date: 00:50 23-02-08


"John Larkin" <jjlarkin@highNOTlandTHIStechnologyPART.com> wrote in
message
news:d1avr35qn25p41ird3dak6ogs0dnb2r37t@4ax.com...
> On Thu, 21 Feb 2008 18:53:19 GMT, "ian field"
<dai.ode@ntlworld.com>
> wrote:
>
>>
>>"me" <me@here.net> wrote in message
>>news:Xns9A4B7EB195C8Cmeherenet@38.119.97.3... /> >>> "ian field" <dai.ode@ntlworld.com> wrote in
>>> news:bTivj.2312$g81.1350@newsfe3-gui.ntli.net:
>>>
>>>>
>>>>"Michael" <news@bigtoes.com> wrote in message
>>>>news:47bdb89f$0$1092$4c368faf@roadrunner.com...
>>>>> ian field wrote:
>>>>>> In a sample fragment of code (EQU section) of a program example
from
>>>>>> 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.
>>>>> It doesn't. Essentially it just wants to convert its operands to
>>>>> 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?
>>>>
>>>>
>>>>
>>> It is the same as;
>>>
>>> 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?
>>
>
> ZEROBIT doesn't mean a file or a bit. It means 2.
>
> Whether it refers to a file, a bit, or a rom address depends on the
> contexts it might be used it. Same as for "2"
>
> John
>

Why is this concept so hard for people to understand? Do they think that the
letters used in the word before the EQU directive have any meaning to the
assembler?

Bob



Author: Greg Neill
Date: 09:18 23-02-08

"Bill Bowden" <wrongaddress@att.net> wrote in message
news:56cd16ad-78e5-4f13-80fb-9a532152eabd@41g2000hsc.googlegroups.com=20
> On Feb 21, 11:01 am, "Greg Neill" <gneill...@OVEsympatico.ca>
wrote:
>> "ian field" <dai....@ntlworld.com> wrote in message
>>=20
>> news:zMjvj.4836$d62.2643@newsfe6-gui.ntli.net
>>=20
>>=20
>>=20
>>> 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?=20
>>=20
>> It doesn't know anything about bits or files. All it
>> knows is that you have assigned the constant 2 to a
>> symbol ZEROBIT. It doesn't know or care what you
>> subsequently do with that symbol.
>>=20
>> However... when it comes across that symbol in code
>> that you write (code that generates instruction
>> sequences), it will substitute the number 2 for the
>> symbol in the context in which it is found. It's up
>> to you to use the symbol in the appropriate context.
>=20
> So how does (COUNTER EQU 20h) differ from (ZEROBIT EQU 02h) ?
> The first (COUNTER) is a file register located at address 20h and can
> be loaded with some value. Why is ZEROBIT any different? Is it not a
> file register located at address 02 without any value assigned?

Presumably you intended both symbols to be=20
EQUivalent to 02h in this example.

There is no difference between them. You could use
symbols interchangeably in the code (much to the
consternation of anyone later trying to debug it)
and the resulting binary code generated by the
assembler would be identical. There is no special
meaning attached to any non reserved word symbol.

What a given defined symbol "means" is entirely up
to the programmer, and is made manifest by how and
where it is used, that is, what code generating=20
instructions it appears in and in what context
(operand, constant, offset, register number,=20
memory address...).


Author: none
Date: 16:52 23-02-08

In article <zMjvj.4836$d62.2643@newsfe6-gui.ntli.net>,
ian field <dai.ode@ntlworld.com> wrote:
>
>"me" <me@here.net> wrote in message
>news:Xns9A4B7EB195C8Cmeherenet@38.119.97.3... /> >> "ian field" <dai.ode@ntlworld.com> wrote in
>> news:bTivj.2312$g81.1350@newsfe3-gui.ntli.net:
>>
>>>
>>>"Michael" <news@bigtoes.com> wrote in message
>>>news:47bdb89f$0$1092$4c368faf@roadrunner.com...
>>>> ian field wrote:
>>>>> In a sample fragment of code (EQU section) of a program example
from
>>>>> 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.
>>>> It doesn't. Essentially it just wants to convert its operands to
>>>> 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?
>>>
>>>
>>>
>> It is the same as;
>>
>> 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?


It doesn't. The usage of label is the determinant. For example this is a
perfectly valid instruction:

btfsz ZEROBIT,ZEROBIT

The first usage of ZEROBIT is a file register, the second a bit number.

BAJ

Author: Bill Bowden
Date: 21:36 23-02-08

On Feb 23, 6:18=A0am, "Greg Neill" <gneill...@OVEsympatico.ca> wrote:
> "Bill Bowden" <wrongaddr...@att.net> wrote in message
>
> news:56cd16ad-78e5-4f13-80fb-9a532152eabd@41g2000hsc.googlegroups.com
>
>
>
>
>
> > On Feb 21, 11:01 am, "Greg Neill" <gneill...@OVEsympatico.ca>
wrote:
> >> "ian field" <dai....@ntlworld.com> wrote in message
>
> >>news:zMjvj.4836$d62.2643@newsfe6-gui.ntli.net
>
> >>> Yes - I know what the EQU section does, but how does the assembler
> >>> know "ZEROBIT =A0 =A0EQU =A0 =A02 ;Zerobit is bit 2" means a
bit and n=
ot a
> >>> file - especially when nothing specifies which file it means bit 2
> >>> of?
>
> >> It doesn't know anything about bits or files. =A0All it
> >> knows is that you have assigned the constant 2 to a
> >> symbol ZEROBIT. =A0It doesn't know or care what you
> >> subsequently do with that symbol.
>
> >> However... when it comes across that symbol in code
> >> that you write (code that generates instruction
> >> sequences), it will substitute the number 2 for the
> >> symbol in the context in which it is found. =A0It's up
> >> to you to use the symbol in the appropriate context.
>
> > So how does (COUNTER =A0 EQU =A0 =A020h) differ from (ZEROBIT =A0 EQU =
=A0 02h) ?
> > The first (COUNTER) is a file register located at address 20h and can
> > be loaded with some value. Why is ZEROBIT any different? Is it not a
> > file register located at address 02 without any value assigned?
>
> Presumably you intended both symbols to be
> EQUivalent to 02h in this example.
>
> There is no difference between them. =A0You could use
> symbols interchangeably in the code (much to the
> consternation of anyone later trying to debug it)
> and the resulting binary code generated by the
> assembler would be identical. =A0There is no special
> meaning attached to any non reserved word symbol.
>
> What a given defined symbol "means" is entirely up
> to the programmer, and is made manifest by how and
> where it is used, that is, what code generating
> instructions it appears in and in what context
> (operand, constant, offset, register number,
> memory address...).- Hide quoted text -
>
> - Show quoted text -

Yes, I get it now. I tried a short program with (BIT EQU 02h) and then
the instruction (bsf PORTB,BIT) and the result was PORTB changed
value to 4 which is right. I've been having trouble with variable bit
assignments and just
used the hard values (bsf PORTB,2) to make it work, but this makes it
much more elegant.

Thanks,

-Bill

1 2


      Contact  |  Electronic Portal


Sci.Electronics.Basics by Keywords
ADC
Antenna
CAD
Coil
Generator
IDE
LCD
Modulator
MOSFET
NiMH
Opamp
Oscilloscope
PID
RS232
Telephone
Transformers
TTL
USB

Sci.Electronics.Basics By Author