"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