A discussion group for the PICMicro microcontroller. Also called the Microchip PIC, this list is dedicated to the use and abuse of this fine, simple, microcontroller. Close to topic posts are welcome, ie. general electronics.
Help with Equates for a Newbie - jsternmd - Sep 6 12:03:41 2009
I am going nuts with a 16F877A project based on siggen3a/IQPro, a DDS project.
Please try to help me understand the following.
In the various forms of DDS code when assembled without any linker file - all single
assembly, there are general equates of the form:
; ******************************************************************
; Set up upper frequency limit = 30,000,000 = 0x01C9C380
limit_3 equ 0x01 ; Most significant byte for 30 MHz
limit_2 equ 0xC9 ; Next byte
limit_1 equ 0xC3 ; Next byte
limit_0 equ 0x80 ; Least significant byte
; ******************************************************************
In the subroutines a simple instruction such as
; ****************************************************
movlw limit_2 ....... moves the value '0xC9' into W
; ****************************************************
Ok, so I add some additonal general equates of identical form directly under these limit_
equates for some customization:
; ******************************************************************
; Set up upper frequency limit = 30,000,000 = 0x01C9C380
limit_3 equ 0x01 ; Most significant byte for 30 MHz
limit_2 equ 0xC9 ; Next byte
limit_1 equ 0xC3 ; Next byte
limit_0 equ 0x80 ; Least significant byte
;
; multiplier = 1000000 hz HFO
mult_3 equ 0x00
mult_2 equ 0x0F
mult_1 equ 0x42
mult_0 equ 0x40
; ******************************************************************
However when try to do the same simple---
; ****************************
movlw mult_1
; ****************************
instead of getting '0x42' into the w register, the assembler places mult_1 at address
'0x42' and the address content is junk for me.
I have looked at these instructions but cannot for the life of me understand how the same
code is being assembled so differently.
Any advice appreciated.
Jerry
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.
(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: Help with Equates for a Newbie - g8fub - Sep 6 12:50:17 2009
Hi Jerry,
I cannot see anything wrong with the equates. I tries to find the original
source code on the web but could only find a version for a PIC16F84. Are you converting
this to run on a PIC16F877 or is there an later version that I did not find? I was going
to try to assemble it to see if I got the same strange result as you. In the symbol table
in the listing is the correct value assigned to mult_1 ?
Les.
--- In p...@yahoogroups.com, "jsternmd"
wrote:
>
> I am going nuts with a 16F877A project based on siggen3a/IQPro, a DDS project.
>
> Please try to help me understand the following.
> In the various forms of DDS code when assembled without any linker file - all single
assembly, there are general equates of the form:
>
> ; ******************************************************************
> ; Set up upper frequency limit = 30,000,000 = 0x01C9C380
> limit_3 equ 0x01 ; Most significant byte for 30 MHz
> limit_2 equ 0xC9 ; Next byte
> limit_1 equ 0xC3 ; Next byte
> limit_0 equ 0x80 ; Least significant byte
> ; ******************************************************************
>
> In the subroutines a simple instruction such as
>
> ; ****************************************************
> movlw limit_2 ....... moves the value '0xC9' into W
> ; ****************************************************
>
> Ok, so I add some additonal general equates of identical form directly under these
limit_ equates for some customization:
>
> ; ******************************************************************
> ; Set up upper frequency limit = 30,000,000 = 0x01C9C380
> limit_3 equ 0x01 ; Most significant byte for 30 MHz
> limit_2 equ 0xC9 ; Next byte
> limit_1 equ 0xC3 ; Next byte
> limit_0 equ 0x80 ; Least significant byte
> ;
> ; multiplier = 1000000 hz HFO
> mult_3 equ 0x00
> mult_2 equ 0x0F
> mult_1 equ 0x42
> mult_0 equ 0x40
> ; ******************************************************************
>
> However when try to do the same simple---
>
> ; ****************************
> movlw mult_1
> ; ****************************
>
> instead of getting '0x42' into the w register, the assembler places mult_1 at address
'0x42' and the address content is junk for me.
> I have looked at these instructions but cannot for the life of me understand how the
same code is being assembled so differently.
>
> Any advice appreciated.
>
> Jerry
>
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )Re: Re: Help with Equates for a Newbie - leon Heller - Sep 6 13:00:16 2009
----- Original Message -----
From: g8fub
To: p...@yahoogroups.com
Sent: Sunday, September 06, 2009 5:49 PM
Subject: [piclist] Re: Help with Equates for a Newbie
Hi Jerry,
I cannot see anything wrong with the equates. I tries to find the original
source code on the web but could only find a version for a PIC16F84. Are you
converting this to run on a PIC16F877 or is there an later version that I
did not find? I was going to try to assemble it to see if I got the same
strange result as you. In the symbol table in the listing is the correct
value assigned to mult_1 ?
Try putting a hash (#) before the symbol.
Leon
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: Re: Help with Equates for a Newbie - leon Heller - Sep 6 13:03:07 2009
----- Original Message -----
From: leon Heller
To: p...@yahoogroups.com
Sent: Sunday, September 06, 2009 6:00 PM
Subject: Re: [piclist] Re: Help with Equates for a Newbie
----- Original Message -----
From: g8fub
To: p...@yahoogroups.com
Sent: Sunday, September 06, 2009 5:49 PM
Subject: [piclist] Re: Help with Equates for a Newbie
Hi Jerry,
I cannot see anything wrong with the equates. I tries to find the original
source code on the web but could only find a version for a PIC16F84. Are you
converting this to run on a PIC16F877 or is there an later version that I
did not find? I was going to try to assemble it to see if I got the same
strange result as you. In the symbol table in the listing is the correct
value assigned to mult_1 ?
Try putting a hash (#) before the symbol.
Sorry, disregard that (worng processsor).
Leon
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
RE: Re: Help with Equates for a Newbie [2 Attachments] - "Jerry O. Stern" - Sep 6 15:10:52 2009
<*>[Attachment(s) from Jerry O. Stern included below]
Hi Les,
Look at these two:
One works one doesn't
73 Jerry
K1JOS
-----Original Message-----
From: p...@yahoogroups.com [mailto:p...@yahoogroups.com] On Behalf
Of g8fub
Sent: Sunday, September 06, 2009 12:50 PM
To: p...@yahoogroups.com
Subject: [piclist] Re: Help with Equates for a Newbie
Hi Jerry,
I cannot see anything wrong with the equates. I tries to find
the original source code on the web but could only find a version for a
PIC16F84. Are you converting this to run on a PIC16F877 or is there an
later version that I did not find? I was going to try to assemble it to
see if I got the same strange result as you. In the symbol table in the
listing is the correct value assigned to mult_1 ? Les.
--- In p...@yahoogroups.com, "jsternmd"
wrote:
>
> I am going nuts with a 16F877A project based on siggen3a/IQPro, a DDS
> project.
>
> Please try to help me understand the following.
> In the various forms of DDS code when assembled without any linker
> file - all single assembly, there are general equates of the form:
>
> ; ******************************************************************
> ; Set up upper frequency limit = 30,000,000 = 0x01C9C380
> limit_3 equ 0x01 ; Most significant byte for 30 MHz
> limit_2 equ 0xC9 ; Next byte
> limit_1 equ 0xC3 ; Next byte
> limit_0 equ 0x80 ; Least significant byte
> ; ******************************************************************
>
> In the subroutines a simple instruction such as
>
> ; ****************************************************
> movlw limit_2 ....... moves the value '0xC9' into W
> ; ****************************************************
>
> Ok, so I add some additonal general equates of identical form directly
> under these limit_ equates for some customization:
>
> ; ******************************************************************
> ; Set up upper frequency limit = 30,000,000 = 0x01C9C380
> limit_3 equ 0x01 ; Most significant byte for 30 MHz
> limit_2 equ 0xC9 ; Next byte
> limit_1 equ 0xC3 ; Next byte
> limit_0 equ 0x80 ; Least significant byte
> ;
> ; multiplier = 1000000 hz HFO
> mult_3 equ 0x00
> mult_2 equ 0x0F
> mult_1 equ 0x42
> mult_0 equ 0x40
> ; ******************************************************************
>
> However when try to do the same simple---
>
> ; ****************************
> movlw mult_1
> ; ****************************
>
> instead of getting '0x42' into the w register, the assembler places
> mult_1 at address '0x42' and the address content is junk for me.
> I have looked at these instructions but cannot for the life of me
> understand how the same code is being assembled so differently.
>
> Any advice appreciated.
>
> Jerry
>
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the
instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )Re: Help with Equates for a Newbie - rtstofer - Sep 6 17:48:11 2009
What assembler are you using?
The constants work fine under MPLAB 8.01
Richard
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.
(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: Help with Equates for a Newbie - g8fub - Sep 6 18:31:09 2009
Hi Jerry,
test.asm seems to assemble correctly so I assume siggen3a_asm.asm is the one
that does not. (You did not say which one worked.) Which constant in which subroutine do
you think is not being assembled correctly ? You should put the correct processor type
statement in and also include the correct processor .inc file. (This specifies the equates
for the registers in the specific processor.) I do not think this will not be the cause
of your equates problem.
Les.
--- In p...@yahoogroups.com, "Jerry O. Stern"
wrote:
>
> Hi Les,
>
> Look at these two:
>
> One works one doesn't
>
> 73 Jerry
> K1JOS
>
> -----Original Message-----
> From: p...@yahoogroups.com [mailto:p...@yahoogroups.com] On Behalf
> Of g8fub
> Sent: Sunday, September 06, 2009 12:50 PM
> To: p...@yahoogroups.com
> Subject: [piclist] Re: Help with Equates for a Newbie
> Hi Jerry,
> I cannot see anything wrong with the equates. I tries to find
> the original source code on the web but could only find a version for a
> PIC16F84. Are you converting this to run on a PIC16F877 or is there an
> later version that I did not find? I was going to try to assemble it to
> see if I got the same strange result as you. In the symbol table in the
> listing is the correct value assigned to mult_1 ? Les.
>
> --- In p...@yahoogroups.com, "jsternmd" wrote:
> >
> > I am going nuts with a 16F877A project based on siggen3a/IQPro, a DDS
> > project.
> >
> > Please try to help me understand the following.
> >
> >
> > In the various forms of DDS code when assembled without any linker
> > file - all single assembly, there are general equates of the form:
> >
> > ; ******************************************************************
> > ; Set up upper frequency limit = 30,000,000 = 0x01C9C380
> > limit_3 equ 0x01 ; Most significant byte for 30 MHz
> > limit_2 equ 0xC9 ; Next byte
> > limit_1 equ 0xC3 ; Next byte
> > limit_0 equ 0x80 ; Least significant byte
> > ; ******************************************************************
> >
> > In the subroutines a simple instruction such as
> >
> > ; ****************************************************
> > movlw limit_2 ....... moves the value '0xC9' into W
> > ; ****************************************************
> >
> > Ok, so I add some additonal general equates of identical form directly
>
> > under these limit_ equates for some customization:
> >
> > ; ******************************************************************
> > ; Set up upper frequency limit = 30,000,000 = 0x01C9C380
> > limit_3 equ 0x01 ; Most significant byte for 30 MHz
> > limit_2 equ 0xC9 ; Next byte
> > limit_1 equ 0xC3 ; Next byte
> > limit_0 equ 0x80 ; Least significant byte
> > ;
> > ; multiplier = 1000000 hz HFO
> > mult_3 equ 0x00
> > mult_2 equ 0x0F
> > mult_1 equ 0x42
> > mult_0 equ 0x40
> > ; ******************************************************************
> >
> > However when try to do the same simple---
> >
> > ; ****************************
> > movlw mult_1
> > ; ****************************
> >
> > instead of getting '0x42' into the w register, the assembler places
> > mult_1 at address '0x42' and the address content is junk for me.
> >
> >
> > I have looked at these instructions but cannot for the life of me
> > understand how the same code is being assembled so differently.
> >
> > Any advice appreciated.
> >
> > Jerry
> >
> ------------------------------------
>
> to unsubscribe, go to http://www.yahoogroups.com and follow the
> instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )Re: Help with Equates for a Newbie - Dwayne Reid - Sep 6 19:54:26 2009
At 10:03 AM 9/6/2009, jsternmd wrote:
>I am going nuts with a 16F877A project based on siggen3a/IQPro, a
>DDS project.
One other thing to try: grab a different version of the assembler
from Microchip. Its a really long shot but you know never know . . .
dwayne
--
Dwayne Reid
Trinity Electronics Systems Ltd Edmonton, AB, CANADA
(780) 489-3199 voice (780) 487-6397 fax
www.trinity-electronics.com
Custom Electronics Design and Manufacturing
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )RE: Re: Help with Equates for a Newbie - "Jerry O. Stern" - Sep 6 21:28:53 2009
Both "assemble" just fine without errors but if you debug thru with a
breakpoint in siggen3a at the first instruction code for limit_2 (or _1
or _3, etc) and check the file register you will see that it contains
the value that is in the general equate statements listed at the top of
the code. However in my test.asm if you do the same and place a
breakpoint on the test_0 or _1 or _2 variable, you will see that the
equate value was used to specify the "address" of the variable and the
contents of the variable name which are shown as 0x00.
-----Original Message-----
From: p...@yahoogroups.com [mailto:p...@yahoogroups.com] On Behalf
Of g8fub
Sent: Sunday, September 06, 2009 6:31 PM
To: p...@yahoogroups.com
Subject: [piclist] Re: Help with Equates for a Newbie
Hi Jerry,
test.asm seems to assemble correctly so I assume
siggen3a_asm.asm is the one that does not. (You did not say which one
worked.) Which constant in which subroutine do you think is not being
assembled correctly ? You should put the correct processor type
statement in and also include the correct processor .inc file. (This
specifies the equates for the registers in the specific processor.) I do
not think this will not be the cause of your equates problem. Les.
--- In p...@yahoogroups.com, "Jerry O. Stern"
wrote:
>
> Hi Les,
>
> Look at these two:
>
> One works one doesn't
>
> 73 Jerry
> K1JOS
>
> -----Original Message-----
> From: p...@yahoogroups.com [mailto:p...@yahoogroups.com] On
> Behalf Of g8fub
> Sent: Sunday, September 06, 2009 12:50 PM
> To: p...@yahoogroups.com
> Subject: [piclist] Re: Help with Equates for a Newbie
> Hi Jerry,
> I cannot see anything wrong with the equates. I tries to
> find the original source code on the web but could only find a version
> for a PIC16F84. Are you converting this to run on a PIC16F877 or is
> there an later version that I did not find? I was going to try to
> assemble it to see if I got the same strange result as you. In the
> symbol table in the listing is the correct value assigned to mult_1 ?
> Les.
>
> --- In p...@yahoogroups.com, "jsternmd" wrote:
> >
> > I am going nuts with a 16F877A project based on siggen3a/IQPro, a
> > DDS
> > project.
> >
> > Please try to help me understand the following.
> >
> >
> > In the various forms of DDS code when assembled without any linker
> > file - all single assembly, there are general equates of the form:
> >
> > ; ******************************************************************
> > ; Set up upper frequency limit = 30,000,000 = 0x01C9C380
> > limit_3 equ 0x01 ; Most significant byte for 30 MHz
> > limit_2 equ 0xC9 ; Next byte
> > limit_1 equ 0xC3 ; Next byte
> > limit_0 equ 0x80 ; Least significant byte
> > ; ******************************************************************
> >
> > In the subroutines a simple instruction such as
> >
> > ; ****************************************************
> > movlw limit_2 ....... moves the value '0xC9' into W
> > ; ****************************************************
> >
> > Ok, so I add some additonal general equates of identical form
> > directly
>
> > under these limit_ equates for some customization:
> >
> > ; ******************************************************************
> > ; Set up upper frequency limit = 30,000,000 = 0x01C9C380
> > limit_3 equ 0x01 ; Most significant byte for 30 MHz
> > limit_2 equ 0xC9 ; Next byte
> > limit_1 equ 0xC3 ; Next byte
> > limit_0 equ 0x80 ; Least significant byte
> > ;
> > ; multiplier = 1000000 hz HFO
> > mult_3 equ 0x00
> > mult_2 equ 0x0F
> > mult_1 equ 0x42
> > mult_0 equ 0x40
> > ; ******************************************************************
> >
> > However when try to do the same simple---
> >
> > ; ****************************
> > movlw mult_1
> > ; ****************************
> >
> > instead of getting '0x42' into the w register, the assembler places
> > mult_1 at address '0x42' and the address content is junk for me.
> >
> >
> > I have looked at these instructions but cannot for the life of me
> > understand how the same code is being assembled so differently.
> >
> > Any advice appreciated.
> >
> > Jerry
> >
> ------------------------------------
>
> to unsubscribe, go to http://www.yahoogroups.com and follow the
> instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )RE: Re: Help with Equates for a Newbie - "Jerry O. Stern" - Sep 6 21:31:32 2009
I am using 8.33... I will switch to 8.01 on a different PC and give it a
try.
-----Original Message-----
From: p...@yahoogroups.com [mailto:p...@yahoogroups.com] On Behalf
Of rtstofer
Sent: Sunday, September 06, 2009 5:48 PM
To: p...@yahoogroups.com
Subject: [piclist] Re: Help with Equates for a Newbie
What assembler are you using?
The constants work fine under MPLAB 8.01
Richard
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the
instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: Help with Equates for a Newbie - rtstofer - Sep 6 22:32:43 2009
I just tried it with version 8.36 and it works fine
Here is the exact code I used:
; ******************************************************************
; Set up upper frequency limit = 30,000,000 = 0x01C9C380
limit_3 equ 0x01 ; Most significant byte for 30 MHz
limit_2 equ 0xC9 ; Next byte
limit_1 equ 0xC3 ; Next byte
limit_0 equ 0x80 ; Least significant byte
; ******************************************************************
; ****************************************************
movlw limit_2
; ****************************************************
; ******************************************************************
; Set up upper frequency limit = 30,000,000 = 0x01C9C380
limit_3 equ 0x01 ; Most significant byte for 30 MHz
limit_2 equ 0xC9 ; Next byte
limit_1 equ 0xC3 ; Next byte
limit_0 equ 0x80 ; Least significant byte
;
; multiplier = 1000000 hz HFO
mult_3 equ 0x00
mult_2 equ 0x0F
mult_1 equ 0x42
mult_0 equ 0x40
; ******************************************************************
; ****************************
movlw mult_1
; ****************************
end
Richard
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
RE: Re: Help with Equates for a Newbie - "Jerry O. Stern" - Sep 6 23:28:23 2009
Hi Richard,
When you say it worked fine.. Do you mean that during debug when you set
breakpoints and looked into the file register contents of limit_2 and
mult_1 the register values were the same as the equates?
What pic did you setup ... the 84A or 877A?
Did you place an include file at the beginning of the asm code or did
you put it into the Header file in the Project view window?
Did you use a linker file?
Thanks for the help
jerry
-----Original Message-----
From: p...@yahoogroups.com [mailto:p...@yahoogroups.com] On Behalf
Of rtstofer
Sent: Sunday, September 06, 2009 10:33 PM
To: p...@yahoogroups.com
Subject: [piclist] Re: Help with Equates for a Newbie
I just tried it with version 8.36 and it works fine
Here is the exact code I used:
; ******************************************************************
; Set up upper frequency limit = 30,000,000 = 0x01C9C380 limit_3 equ
0x01 ; Most significant byte for 30 MHz limit_2 equ 0xC9 ; Next byte
limit_1 equ 0xC3 ; Next byte limit_0 equ 0x80 ; Least significant byte ;
******************************************************************
; ****************************************************
movlw limit_2
; ****************************************************
; ******************************************************************
; Set up upper frequency limit = 30,000,000 = 0x01C9C380 limit_3 equ
0x01 ; Most significant byte for 30 MHz limit_2 equ 0xC9 ; Next byte
limit_1 equ 0xC3 ; Next byte limit_0 equ 0x80 ; Least significant byte ;
; multiplier = 1000000 hz HFO mult_3 equ 0x00 mult_2 equ 0x0F mult_1 equ
0x42 mult_0 equ 0x40 ;
******************************************************************
; ****************************
movlw mult_1
; ****************************
end
Richard
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the
instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: Help with Equates for a Newbie - rtstofer - Sep 6 23:50:37 2009
--- In p...@yahoogroups.com, "Jerry O. Stern"
wrote:
>
> Hi Richard,
>
> When you say it worked fine.. Do you mean that during debug when you set
> breakpoints and looked into the file register contents of limit_2 and
> mult_1 the register values were the same as the equates?
>
> What pic did you setup ... the 84A or 877A?
>
> Did you place an include file at the beginning of the asm code or did
> you put it into the Header file in the Project view window?
>
> Did you use a linker file?
>
> Thanks for the help
I didn't do anything other than create a new project for the 16F877 using the project
wizard. Then I created a .asm file and added it to the project. I pasted your code,
removed the extraeous comments and added an end statement. Then I assembled the code and
looked at the .lst file. The code is correct.
I didn't add a header file primarily because it wasn't necessary for two instructions. I
wasn't using any specific SFRs. I tried adding the appropriate p16f877.inc file and the
results were identical.
I did not use a debugger nor did I download the code. The .hex file looks fine.
I thought your problem was with assembling the code, not debugging it. I guess I could
have deduced that from your original post but I don't tend to use debuggers so I didn't
spend a lot of time thinking about it.
Richard
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )RE: Re: Help with Equates for a Newbie - "Jerry O. Stern" - Sep 7 0:12:54 2009
Would you be able to run MPASM debug and confirm with your project code
whether the equates register values are correct in the variable
registers for limit_ and test_
Thanks
jerry
-----Original Message-----
From: p...@yahoogroups.com [mailto:p...@yahoogroups.com] On Behalf
Of rtstofer
Sent: Sunday, September 06, 2009 11:49 PM
To: p...@yahoogroups.com
Subject: [piclist] Re: Help with Equates for a Newbie
--- In p...@yahoogroups.com, "Jerry O. Stern"
wrote:
>
> Hi Richard,
>
> When you say it worked fine.. Do you mean that during debug when you
> set breakpoints and looked into the file register contents of limit_2
> and mult_1 the register values were the same as the equates?
>
> What pic did you setup ... the 84A or 877A?
>
> Did you place an include file at the beginning of the asm code or did
> you put it into the Header file in the Project view window?
>
> Did you use a linker file?
>
> Thanks for the help
I didn't do anything other than create a new project for the 16F877
using the project wizard. Then I created a .asm file and added it to
the project. I pasted your code, removed the extraeous comments and
added an end statement. Then I assembled the code and looked at the
.lst file. The code is correct.
I didn't add a header file primarily because it wasn't necessary for two
instructions. I wasn't using any specific SFRs. I tried adding the
appropriate p16f877.inc file and the results were identical.
I did not use a debugger nor did I download the code. The .hex file
looks fine.
I thought your problem was with assembling the code, not debugging it.
I guess I could have deduced that from your original post but I don't
tend to use debuggers so I didn't spend a lot of time thinking about it.
Richard
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the
instructions
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )Re: Help with Equates for a Newbie - rtstofer - Sep 7 1:27:38 2009
--- In p...@yahoogroups.com, "Jerry O. Stern"
wrote:
>
> Would you be able to run MPASM debug and confirm with your project code
> whether the equates register values are correct in the variable
> registers for limit_ and test_
>
> Thanks
> jerry
Let me think about it. I don't have a development board at the moment but I must have
something laying around. I'll have to look into using a debugger.
Richard
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )RE: Re: Help with Equates for a Newbie - Dave Wade - Sep 7 3:03:00 2009
> -----Original Message-----
> From: p...@yahoogroups.com [mailto:p...@yahoogroups.com] On Behalf
> Of g8fub
> Sent: 06 September 2009 17:50
> To: p...@yahoogroups.com
> Subject: [piclist] Re: Help with Equates for a Newbie
>
> Hi Jerry,
> I cannot see anything wrong with the equates. I tries to find
> the original source code on the web but could only find a version for a
> PIC16F84. Are you converting this to run on a PIC16F877 or is there an
> later version that I did not find? I was going to try to assemble it to
> see if I got the same strange result as you. In the symbol table in the
> listing is the correct value assigned to mult_1 ?
> Les.
>
> --- In p...@yahoogroups.com, "jsternmd"
wrote:
> >
> > I am going nuts with a 16F877A project based on siggen3a/IQPro, a DDS
> project.
> >
> > Please try to help me understand the following.
> >
> >
> > In the various forms of DDS code when assembled without any linker file
> - all single assembly, there are general equates of the form:
> >
> > ; ******************************************************************
> > ; Set up upper frequency limit = 30,000,000 = 0x01C9C380
> > limit_3 equ 0x01 ; Most significant byte for 30 MHz
> > limit_2 equ 0xC9 ; Next byte
> > limit_1 equ 0xC3 ; Next byte
> > limit_0 equ 0x80 ; Least significant byte
> > ; ******************************************************************
> >
> > In the subroutines a simple instruction such as
> >
> > ; ****************************************************
> > movlw limit_2 ....... moves the value '0xC9' into W
> > ; ****************************************************
> >
> > Ok, so I add some additonal general equates of identical form directly
> under these limit_ equates for some customization:
> >
> > ; ******************************************************************
> > ; Set up upper frequency limit = 30,000,000 = 0x01C9C380
> > limit_3 equ 0x01 ; Most significant byte for 30 MHz
> > limit_2 equ 0xC9 ; Next byte
> > limit_1 equ 0xC3 ; Next byte
> > limit_0 equ 0x80 ; Least significant byte
> > ;
> > ; multiplier = 1000000 hz HFO
> > mult_3 equ 0x00
> > mult_2 equ 0x0F
> > mult_1 equ 0x42
> > mult_0 equ 0x40
> > ; ******************************************************************
> >
> > However when try to do the same simple---
> >
> > ; ****************************
> > movlw mult_1
> > ; ****************************
> >
> > instead of getting '0x42' into the w register, the assembler places
> mult_1 at address '0x42' and the address content is junk for me.
"mult_1" is just a constant. It is treated as the address of a file register
if the instruction wants an address, its treated as a constant of 0x42 if
the instruction needs a constant. As from what I remember "movlw" moves a
literal constant to the "W" register, it should contain "0x42" after the
above instruction has been executed. Can you post the relevant bit of the
".lst" files showing how its been assembled, where its different, which is
right and which is wrong?
> >
> >
> > I have looked at these instructions but cannot for the life of me
> understand how the same code is being assembled so differently.
> >
> > Any advice appreciated.
> >
> > Jerry
>
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )RE: Re: Help with Equates for a Newbie - Jan Didden / Linear Audio - Sep 7 4:01:38 2009
Is it possible that the labels mult_1 etc are (re)defined in an header or
include file?
Jan Didden
Linear Audio
_____
From: p...@yahoogroups.com [mailto:p...@yahoogroups.com] On Behalf Of
rtstofer
Sent: Sunday, September 06, 2009 11:48 PM
To: p...@yahoogroups.com
Subject: [piclist] Re: Help with Equates for a Newbie
What assembler are you using?
The constants work fine under MPLAB 8.01
Richard
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.
(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: Help with Equates for a Newbie - g8fub - Sep 7 4:11:28 2009
Hi Jerry,
I do not understand your statement "looked into the file register" Your code is
not putting anything into any file register.
You have defined five file registers.
freq_0 ; Register 20 (All register bank 0)
freq_1 ; Register 21
freq_2 ; Register 22
freq_3 ; Register 23
scratch ; Register 24
All you are doing is to put the constant limit_1 or test_1 into "W"
so the only thing you should see is the value of "W" being set to the constant limit_1 or
test_1 As you have defined both of these constants to have the value 0xC3 so the value of
"W" should become 0xC3 If you look at the list file you will see that both movlw
instructions assemble to 30C3 which is correct. Writing movlw limit_1 or movlw test_1 is
exactly the same as movlw 0xC3
If you want the value of the constant to be put in a file register you need to follow the
movlw instruction by a movwf instruction.
movlw limit_1 ;Sets the value of "W" to 0xC3
movwf freq_1 ; moves the value from "W" to register 0x21 (Which you have given
the label freq_1)
If you had not used any names for registers or constants the code would be.
movlw 0xC3
mofwf 0x21
If you look at the symbol table in the list file you should see
limit_1 000000C3
test_1 000000C3
freq_1 00000021
All the equate statement does is to give a numeric value to a label.
I think using the debugger is just confusing you.
Les.
--- In p...@yahoogroups.com, "Jerry O. Stern"
wrote:
>
> Hi Richard,
>
> When you say it worked fine.. Do you mean that during debug when you set
> breakpoints and looked into the file register contents of limit_2 and
> mult_1 the register values were the same as the equates?
>
> What pic did you setup ... the 84A or 877A?
>
> Did you place an include file at the beginning of the asm code or did
> you put it into the Header file in the Project view window?
>
> Did you use a linker file?
>
> Thanks for the help
>
> jerry
>
> -----Original Message-----
> From: p...@yahoogroups.com [mailto:p...@yahoogroups.com] On Behalf
> Of rtstofer
> Sent: Sunday, September 06, 2009 10:33 PM
> To: p...@yahoogroups.com
> Subject: [piclist] Re: Help with Equates for a Newbie
> I just tried it with version 8.36 and it works fine
>
> Here is the exact code I used:
>
> ; ******************************************************************
> ; Set up upper frequency limit = 30,000,000 = 0x01C9C380 limit_3 equ
> 0x01 ; Most significant byte for 30 MHz limit_2 equ 0xC9 ; Next byte
> limit_1 equ 0xC3 ; Next byte limit_0 equ 0x80 ; Least significant byte ;
> ******************************************************************
>
> ; ****************************************************
> movlw limit_2
> ; ****************************************************
>
> ; ******************************************************************
> ; Set up upper frequency limit = 30,000,000 = 0x01C9C380 limit_3 equ
> 0x01 ; Most significant byte for 30 MHz limit_2 equ 0xC9 ; Next byte
> limit_1 equ 0xC3 ; Next byte limit_0 equ 0x80 ; Least significant byte ;
> ; multiplier = 1000000 hz HFO mult_3 equ 0x00 mult_2 equ 0x0F mult_1 equ
> 0x42 mult_0 equ 0x40 ;
> ******************************************************************
>
> ; ****************************
> movlw mult_1
> ; ****************************
>
> end
> Richard
> ------------------------------------
>
> to unsubscribe, go to http://www.yahoogroups.com and follow the
> instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )Re: Help with Equates for a Newbie - rtstofer - Sep 7 10:15:59 2009
--- In p...@yahoogroups.com, "Jerry O. Stern"
wrote:
>
> Would you be able to run MPASM debug and confirm with your project code
> whether the equates register values are correct in the variable
> registers for limit_ and test_
>
> Thanks
> jerry
>
Something is wrong with my PicKit2. WiinXP doesn't recognize it and MPLAB can't connect
to it. I'll have to look into it one of these days.
Richard
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )RE: Re: Help with Equates for a Newbie [2 Attachments] - "Jerry O. Stern" - Sep 7 10:17:00 2009
<*>[Attachment(s) from Jerry O. Stern included below]
Hi Richard,
Please be patient with me and let me try to be more clear.
I understand your explanation completely and that is how I understood
the way the PIC instructions should work BUT I have a project code from
a digital synthesizer project called siggen3a. Somehow when this same
appearing code is assembled, the equates are not interpreted as label
addresses. For example in the code snippet below e.g., the equ are NOT
assigning address 0x01 to limit_1 or address 0xC9 to limit_2 but instead
is assigning the shown values as the register values contained in the
address of the respective label. The limit_3,2,1,0 is a 32 bit hex
01C9C380 = decimal 30,000,000 that represents 30.000000 megahertz
frequency and not some peculiar address assignments. The actual
addreeses being assigned seem rather random.
What is curious about the way this code is written is that these values
are not treated as assembler constants but during run-time the code can
change their values. It just seems like a very efficient method and I
wanted to understand how this code achieves it since when I have tried
to do the same in new code it works only as you described.
-----------------
limit_3 equ 0x01 ; Most significant byte for 30 MHz
limit_2 equ 0xC9 ; Next byte
limit_1 equ 0xC3 ; Next byte
limit_0 equ 0x80 ; Least significant byte
--------------------------------------
-----Original Message-----
From: p...@yahoogroups.com [mailto:p...@yahoogroups.com] On Behalf
Of g8fub
Sent: Monday, September 07, 2009 4:11 AM
To: p...@yahoogroups.com
Subject: [piclist] Re: Help with Equates for a Newbie
Hi Jerry,
I do not understand your statement "looked into the file
register" Your code is not putting anything into any file register. You
have defined five file registers.
freq_0 ; Register 20 (All register bank 0)
freq_1 ; Register 21
freq_2 ; Register 22
freq_3 ; Register 23
scratch ; Register 24
All you are doing is to put the constant limit_1 or test_1 into "W" so
the only thing you should see is the value of "W" being set to the
constant limit_1 or test_1 As you have defined both of these constants
to have the value 0xC3 so the value of "W" should become 0xC3 If you
look at the list file you will see that both movlw instructions assemble
to 30C3 which is correct. Writing movlw limit_1 or movlw test_1 is
exactly the same as movlw 0xC3 If you want the value of the constant to
be put in a file register you need to follow the movlw instruction by a
movwf instruction.
movlw limit_1 ;Sets the value of "W" to 0xC3
movwf freq_1 ; moves the value from "W" to register 0x21
(Which you have given the label freq_1)
If you had not used any names for registers or constants the code would
be.
movlw 0xC3
mofwf 0x21
If you look at the symbol table in the list file you should see
limit_1 000000C3
test_1 000000C3
freq_1 00000021
All the equate statement does is to give a numeric value to a label.
I think using the debugger is just confusing you.
Les.
--- In p...@yahoogroups.com, "Jerry O. Stern"
wrote:
>
> Hi Richard,
>
> When you say it worked fine.. Do you mean that during debug when you
> set breakpoints and looked into the file register contents of limit_2
> and mult_1 the register values were the same as the equates?
>
> What pic did you setup ... the 84A or 877A?
>
> Did you place an include file at the beginning of the asm code or did
> you put it into the Header file in the Project view window?
>
> Did you use a linker file?
>
> Thanks for the help
>
> jerry
>
> -----Original Message-----
> From: p...@yahoogroups.com [mailto:p...@yahoogroups.com] On
> Behalf Of rtstofer
> Sent: Sunday, September 06, 2009 10:33 PM
> To: p...@yahoogroups.com
> Subject: [piclist] Re: Help with Equates for a Newbie
> I just tried it with version 8.36 and it works fine
>
> Here is the exact code I used:
>
> ; ******************************************************************
> ; Set up upper frequency limit = 30,000,000 = 0x01C9C380 limit_3 equ
> 0x01 ; Most significant byte for 30 MHz limit_2 equ 0xC9 ; Next byte
> limit_1 equ 0xC3 ; Next byte limit_0 equ 0x80 ; Least significant byte
> ;
> ******************************************************************
>
> ; ****************************************************
> movlw limit_2
> ; ****************************************************
>
> ; ******************************************************************
> ; Set up upper frequency limit = 30,000,000 = 0x01C9C380 limit_3 equ
> 0x01 ; Most significant byte for 30 MHz limit_2 equ 0xC9 ; Next byte
> limit_1 equ 0xC3 ; Next byte limit_0 equ 0x80 ; Least significant byte
> ; ; multiplier = 1000000 hz HFO mult_3 equ 0x00 mult_2 equ 0x0F mult_1
> equ 0x42 mult_0 equ 0x40 ;
> ******************************************************************
>
> ; ****************************
> movlw mult_1
> ; ****************************
>
> end
> Richard
> ------------------------------------
>
> to unsubscribe, go to http://www.yahoogroups.com and follow the
> instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )RE: Re: Help with Equates for a Newbie - "Jerry O. Stern" - Sep 7 10:17:52 2009
No I looked at that. Anyone who would like to see the source code
siggen3a please let me know and I will send to you.
-----Original Message-----
From: p...@yahoogroups.com [mailto:p...@yahoogroups.com] On Behalf
Of Jan Didden / Linear Audio
Sent: Monday, September 07, 2009 3:56 AM
To: p...@yahoogroups.com
Subject: RE: [piclist] Re: Help with Equates for a Newbie
Is it possible that the labels mult_1 etc are (re)defined in an header
or include file?
Jan Didden
Linear Audio
_____
From: p...@yahoogroups.com [mailto:p...@yahoogroups.com] On Behalf
Of rtstofer
Sent: Sunday, September 06, 2009 11:48 PM
To: p...@yahoogroups.com
Subject: [piclist] Re: Help with Equates for a Newbie
What assembler are you using?
The constants work fine under MPLAB 8.01
Richard
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.
(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: Help with Equates for a Newbie - g8fub - Sep 7 13:53:55 2009
Hi Jerry,
siggen3a.asm only ever uses limit_0,1,2,3 as a constant. Their values are not
changed in the program. If you do a search of the source file looking for "limit_" you
will only find them with the movlw instruction either directly or subtracted from 0xFF.(
The assembler does this calculation so for the instruction
movlw 0xFF - limit_1 this means movlw 0xFF - 0xC3 which is movlw 0x3C)
If you look at the list file line number 801 you will see the movlw instruction assembles
to 303C the 30 is the movlw and the 3C the value associated with it.
Les.
--- In p...@yahoogroups.com, "Jerry O. Stern"
wrote:
>
> Hi Richard,
>
> Please be patient with me and let me try to be more clear.
>
> I understand your explanation completely and that is how I understood
> the way the PIC instructions should work BUT I have a project code from
> a digital synthesizer project called siggen3a. Somehow when this same
> appearing code is assembled, the equates are not interpreted as label
> addresses. For example in the code snippet below e.g., the equ are NOT
> assigning address 0x01 to limit_1 or address 0xC9 to limit_2 but instead
> is assigning the shown values as the register values contained in the
> address of the respective label. The limit_3,2,1,0 is a 32 bit hex
> 01C9C380 = decimal 30,000,000 that represents 30.000000 megahertz
> frequency and not some peculiar address assignments. The actual
> addreeses being assigned seem rather random.
>
> What is curious about the way this code is written is that these values
> are not treated as assembler constants but during run-time the code can
> change their values. It just seems like a very efficient method and I
> wanted to understand how this code achieves it since when I have tried
> to do the same in new code it works only as you described.
>
> -----------------
> limit_3 equ 0x01 ; Most significant byte for 30 MHz
> limit_2 equ 0xC9 ; Next byte
> limit_1 equ 0xC3 ; Next byte
> limit_0 equ 0x80 ; Least significant byte
>
> --------------------------------------
> -----Original Message-----
> From: p...@yahoogroups.com [mailto:p...@yahoogroups.com] On Behalf
> Of g8fub
> Sent: Monday, September 07, 2009 4:11 AM
> To: p...@yahoogroups.com
> Subject: [piclist] Re: Help with Equates for a Newbie
> Hi Jerry,
> I do not understand your statement "looked into the file
> register" Your code is not putting anything into any file register. You
> have defined five file registers.
>
> freq_0 ; Register 20 (All register bank 0)
> freq_1 ; Register 21
> freq_2 ; Register 22
> freq_3 ; Register 23
> scratch ; Register 24
>
> All you are doing is to put the constant limit_1 or test_1 into "W" so
> the only thing you should see is the value of "W" being set to the
> constant limit_1 or test_1 As you have defined both of these constants
> to have the value 0xC3 so the value of "W" should become 0xC3 If you
> look at the list file you will see that both movlw instructions assemble
> to 30C3 which is correct. Writing movlw limit_1 or movlw test_1 is
> exactly the same as movlw 0xC3 If you want the value of the constant to
> be put in a file register you need to follow the movlw instruction by a
> movwf instruction.
>
> movlw limit_1 ;Sets the value of "W" to 0xC3
> movwf freq_1 ; moves the value from "W" to register 0x21
> (Which you have given the label freq_1)
>
> If you had not used any names for registers or constants the code would
> be.
> movlw 0xC3
> mofwf 0x21
>
> If you look at the symbol table in the list file you should see
>
> limit_1 000000C3
>
> test_1 000000C3
>
> freq_1 00000021
>
> All the equate statement does is to give a numeric value to a label.
>
> I think using the debugger is just confusing you.
> Les.
> --- In p...@yahoogroups.com, "Jerry O. Stern" wrote:
> >
> > Hi Richard,
> >
> > When you say it worked fine.. Do you mean that during debug when you
> > set breakpoints and looked into the file register contents of limit_2
> > and mult_1 the register values were the same as the equates?
> >
> > What pic did you setup ... the 84A or 877A?
> >
> > Did you place an include file at the beginning of the asm code or did
> > you put it into the Header file in the Project view window?
> >
> > Did you use a linker file?
> >
> > Thanks for the help
> >
> > jerry
> >
> > -----Original Message-----
> > From: p...@yahoogroups.com [mailto:p...@yahoogroups.com] On
> > Behalf Of rtstofer
> > Sent: Sunday, September 06, 2009 10:33 PM
> > To: p...@yahoogroups.com
> > Subject: [piclist] Re: Help with Equates for a Newbie
> >
> >
> > I just tried it with version 8.36 and it works fine
> >
> > Here is the exact code I used:
> >
> > ; ******************************************************************
> > ; Set up upper frequency limit = 30,000,000 = 0x01C9C380 limit_3 equ
> > 0x01 ; Most significant byte for 30 MHz limit_2 equ 0xC9 ; Next byte
> > limit_1 equ 0xC3 ; Next byte limit_0 equ 0x80 ; Least significant byte
>
> > ;
> > ******************************************************************
> >
> > ; ****************************************************
> > movlw limit_2
> > ; ****************************************************
> >
> > ; ******************************************************************
> > ; Set up upper frequency limit = 30,000,000 = 0x01C9C380 limit_3 equ
> > 0x01 ; Most significant byte for 30 MHz limit_2 equ 0xC9 ; Next byte
> > limit_1 equ 0xC3 ; Next byte limit_0 equ 0x80 ; Least significant byte
>
> > ; ; multiplier = 1000000 hz HFO mult_3 equ 0x00 mult_2 equ 0x0F mult_1
>
> > equ 0x42 mult_0 equ 0x40 ;
> > ******************************************************************
> >
> > ; ****************************
> > movlw mult_1
> > ; ****************************
> >
> > end
> >
> >
> > Richard
> >
> >
> >
> >
> > ------------------------------------
> >
> > to unsubscribe, go to http://www.yahoogroups.com and follow the
> > instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )Re: Help with Equates for a Newbie - rtstofer - Sep 7 14:59:47 2009
--- In p...@yahoogroups.com, "Jerry O. Stern"
wrote:
>
> Hi Richard,
>
> Please be patient with me and let me try to be more clear.
>
> I understand your explanation completely and that is how I understood
> the way the PIC instructions should work BUT I have a project code from
> a digital synthesizer project called siggen3a. Somehow when this same
> appearing code is assembled, the equates are not interpreted as label
> addresses. For example in the code snippet below e.g., the equ are NOT
> assigning address 0x01 to limit_1 or address 0xC9 to limit_2 but instead
> is assigning the shown values as the register values contained in the
> address of the respective label. The limit_3,2,1,0 is a 32 bit hex
> 01C9C380 = decimal 30,000,000 that represents 30.000000 megahertz
> frequency and not some peculiar address assignments. The actual
> addreeses being assigned seem rather random.
>
> What is curious about the way this code is written is that these values
> are not treated as assembler constants but during run-time the code can
> change their values. It just seems like a very efficient method and I
> wanted to understand how this code achieves it since when I have tried
> to do the same in new code it works only as you described.
>
> -----------------
> limit_3 equ 0x01 ; Most significant byte for 30 MHz
> limit_2 equ 0xC9 ; Next byte
> limit_1 equ 0xC3 ; Next byte
> limit_0 equ 0x80 ; Least significant byte
>
> --------------------------------------
I didn't mean to be impatient. If I appeared to be so, just ignore it.
I understood that the movlw limit_1 statement put the literal constant 0xC3 into the W
register. Nothing more, nothing less. No code was shown where the value in the W
register was stored in memory. So, I didn't expect that it was.
But your example defines limit_1 to be a literal constant, not a memory address (I hope).
Of course, it could BE an address if you chose to treat it that was. What 0xC3 'means'
depends entirely on the way in which you use it.
For example:
limit_1 EQU 0xC3
movlw limit_1 ; load W with the constant value 0xC3
movwf limit_1 ; put the contents of W into memory at 0xC3
I have a huge problem with using EQU to define memory addresses. One simple change and
the whole thing falls apart. I have complained many times that when I see a program that
contains register definitions using EQUs (rather than an .inc file) and then uses EQUs to
define memory addresses as well as literal constants that the program is a good example of
really bad programming.
There is a reason the CBLOCK concept was created. It works well for allocating memory.
There is a reason that .inc files were created. It hides a lot of stuff that you don't
need to see in the source file. Then you can use EQU to define literal constants.
Nothing more, nothing less. They are constants, not memory locations.
Richard
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )Re: Help with Equates for a Newbie - jandidden - Sep 7 14:59:53 2009
Have you tried
#define limit_1 oxff
to see how that works out?
Jan Didden
--- In p...@yahoogroups.com, "g8fub"
wrote:
>
> Hi Jerry,
> siggen3a.asm only ever uses limit_0,1,2,3 as a constant. Their values are not
changed in the program. If you do a search of the source file looking for "limit_" you
will only find them with the movlw instruction either directly or subtracted from 0xFF.(
The assembler does this calculation so for the instruction
> movlw 0xFF - limit_1 this means movlw 0xFF - 0xC3 which is movlw 0x3C)
> If you look at the list file line number 801 you will see the movlw instruction
assembles to 303C the 30 is the movlw and the 3C the value associated with it.
> Les.
>
> --- In p...@yahoogroups.com, "Jerry O. Stern" wrote:
> >
> > Hi Richard,
> >
> > Please be patient with me and let me try to be more clear.
> >
> > I understand your explanation completely and that is how I understood
> > the way the PIC instructions should work BUT I have a project code from
> > a digital synthesizer project called siggen3a. Somehow when this same
> > appearing code is assembled, the equates are not interpreted as label
> > addresses. For example in the code snippet below e.g., the equ are NOT
> > assigning address 0x01 to limit_1 or address 0xC9 to limit_2 but instead
> > is assigning the shown values as the register values contained in the
> > address of the respective label. The limit_3,2,1,0 is a 32 bit hex
> > 01C9C380 = decimal 30,000,000 that represents 30.000000 megahertz
> > frequency and not some peculiar address assignments. The actual
> > addreeses being assigned seem rather random.
> >
> > What is curious about the way this code is written is that these values
> > are not treated as assembler constants but during run-time the code can
> > change their values. It just seems like a very efficient method and I
> > wanted to understand how this code achieves it since when I have tried
> > to do the same in new code it works only as you described.
> >
> >
> >
> > -----------------
> > limit_3 equ 0x01 ; Most significant byte for 30 MHz
> > limit_2 equ 0xC9 ; Next byte
> > limit_1 equ 0xC3 ; Next byte
> > limit_0 equ 0x80 ; Least significant byte
> >
> > --------------------------------------
> >
> >
> >
> >
> >
> >
> > -----Original Message-----
> > From: p...@yahoogroups.com [mailto:p...@yahoogroups.com] On Behalf
> > Of g8fub
> > Sent: Monday, September 07, 2009 4:11 AM
> > To: p...@yahoogroups.com
> > Subject: [piclist] Re: Help with Equates for a Newbie
> >
> >
> > Hi Jerry,
> > I do not understand your statement "looked into the file
> > register" Your code is not putting anything into any file register. You
> > have defined five file registers.
> >
> > freq_0 ; Register 20 (All register bank 0)
> > freq_1 ; Register 21
> > freq_2 ; Register 22
> > freq_3 ; Register 23
> > scratch ; Register 24
> >
> > All you are doing is to put the constant limit_1 or test_1 into "W" so
> > the only thing you should see is the value of "W" being set to the
> > constant limit_1 or test_1 As you have defined both of these constants
> > to have the value 0xC3 so the value of "W" should become 0xC3 If you
> > look at the list file you will see that both movlw instructions assemble
> > to 30C3 which is correct. Writing movlw limit_1 or movlw test_1 is
> > exactly the same as movlw 0xC3 If you want the value of the constant to
> > be put in a file register you need to follow the movlw instruction by a
> > movwf instruction.
> >
> > movlw limit_1 ;Sets the value of "W" to 0xC3
> > movwf freq_1 ; moves the value from "W" to register 0x21
> > (Which you have given the label freq_1)
> >
> > If you had not used any names for registers or constants the code would
> > be.
> > movlw 0xC3
> > mofwf 0x21
> >
> > If you look at the symbol table in the list file you should see
> >
> > limit_1 000000C3
> >
> > test_1 000000C3
> >
> > freq_1 00000021
> >
> > All the equate statement does is to give a numeric value to a label.
> >
> > I think using the debugger is just confusing you.
> > Les.
> >
> >
> > --- In p...@yahoogroups.com, "Jerry O. Stern" wrote:
> > >
> > > Hi Richard,
> > >
> > > When you say it worked fine.. Do you mean that during debug when you
> > > set breakpoints and looked into the file register contents of limit_2
> > > and mult_1 the register values were the same as the equates?
> > >
> > > What pic did you setup ... the 84A or 877A?
> > >
> > > Did you place an include file at the beginning of the asm code or did
> > > you put it into the Header file in the Project view window?
> > >
> > > Did you use a linker file?
> > >
> > > Thanks for the help
> > >
> > > jerry
> > >
> > > -----Original Message-----
> > > From: p...@yahoogroups.com [mailto:p...@yahoogroups.com] On
> > > Behalf Of rtstofer
> > > Sent: Sunday, September 06, 2009 10:33 PM
> > > To: p...@yahoogroups.com
> > > Subject: [piclist] Re: Help with Equates for a Newbie
> > >
> > >
> > > I just tried it with version 8.36 and it works fine
> > >
> > > Here is the exact code I used:
> > >
> > > ; ******************************************************************
> > > ; Set up upper frequency limit = 30,000,000 = 0x01C9C380 limit_3 equ
> > > 0x01 ; Most significant byte for 30 MHz limit_2 equ 0xC9 ; Next byte
> > > limit_1 equ 0xC3 ; Next byte limit_0 equ 0x80 ; Least significant byte
> >
> > > ;
> > > ******************************************************************
> > >
> > > ; ****************************************************
> > > movlw limit_2
> > > ; ****************************************************
> > >
> > > ; ******************************************************************
> > > ; Set up upper frequency limit = 30,000,000 = 0x01C9C380 limit_3 equ
> > > 0x01 ; Most significant byte for 30 MHz limit_2 equ 0xC9 ; Next byte
> > > limit_1 equ 0xC3 ; Next byte limit_0 equ 0x80 ; Least significant byte
> >
> > > ; ; multiplier = 1000000 hz HFO mult_3 equ 0x00 mult_2 equ 0x0F mult_1
> >
> > > equ 0x42 mult_0 equ 0x40 ;
> > > ******************************************************************
> > >
> > > ; ****************************
> > > movlw mult_1
> > > ; ****************************
> > >
> > > end
> > >
> > >
> > > Richard
> > >
> > >
> > >
> > >
> > > ------------------------------------
> > >
> > > to unsubscribe, go to http://www.yahoogroups.com and follow the
> > > instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )RE: Re: Help with Equates for a Newbie - "Jerry O. Stern" - Sep 8 6:09:55 2009
Les,
Many thanks I see where my confusion comes from. In the list (lst) file
and in the file register window these 'constants' appear at GPR
addresses (0x20 - 0x7F) equal to their "constant" value. I now see that
even in places where the constant symbol name replaces what should be
another variable name from the cblock assignment, that the contents of
the address correspond to the cblock variable despite the symbol name
being incorrect. So, it appears to be a MPLAB glitch? I moved up to
v8.36 but no change in this regards.
Thanks again for all your help, it is very appreciated. On some days I
think I am really making progress learning PIC coding and then there are
times when I wrack my brain until kind people like you and others on the
PIClist take time to help out.
jerry
-----Original Message-----
From: p...@yahoogroups.com [mailto:p...@yahoogroups.com] On Behalf
Of g8fub
Sent: Monday, September 07, 2009 1:53 PM
To: p...@yahoogroups.com
Subject: [piclist] Re: Help with Equates for a Newbie
Hi Jerry,
siggen3a.asm only ever uses limit_0,1,2,3 as a constant. Their
values are not changed in the program. If you do a search of the source
file looking for "limit_" you will only find them with the movlw
instruction either directly or subtracted from 0xFF.( The assembler does
this calculation so for the instruction
movlw 0xFF - limit_1 this means movlw 0xFF - 0xC3 which is movlw 0x3C)
If you look at the list file line number 801 you will see the movlw
instruction assembles to 303C the 30 is the movlw and the 3C the value
associated with it.
Les.
--- In p...@yahoogroups.com, "Jerry O. Stern"
wrote:
>
> Hi Richard,
>
> Please be patient with me and let me try to be more clear.
>
> I understand your explanation completely and that is how I understood
> the way the PIC instructions should work BUT I have a project code
> from a digital synthesizer project called siggen3a. Somehow when this
> same appearing code is assembled, the equates are not interpreted as
> label addresses. For example in the code snippet below e.g., the equ
> are NOT assigning address 0x01 to limit_1 or address 0xC9 to limit_2
> but instead is assigning the shown values as the register values
> contained in the address of the respective label. The limit_3,2,1,0
> is a 32 bit hex 01C9C380 = decimal 30,000,000 that represents
> 30.000000 megahertz frequency and not some peculiar address
> assignments. The actual addreeses being assigned seem rather random.
>
> What is curious about the way this code is written is that these
> values are not treated as assembler constants but during run-time the
> code can change their values. It just seems like a very efficient
> method and I wanted to understand how this code achieves it since when
> I have tried to do the same in new code it works only as you
> described.
>
> -----------------
> limit_3 equ 0x01 ; Most significant byte for 30 MHz
> limit_2 equ 0xC9 ; Next byte
> limit_1 equ 0xC3 ; Next byte
> limit_0 equ 0x80 ; Least significant byte
>
> --------------------------------------
> -----Original Message-----
> From: p...@yahoogroups.com [mailto:p...@yahoogroups.com] On
> Behalf Of g8fub
> Sent: Monday, September 07, 2009 4:11 AM
> To: p...@yahoogroups.com
> Subject: [piclist] Re: Help with Equates for a Newbie
> Hi Jerry,
> I do not understand your statement "looked into the file
> register" Your code is not putting anything into any file register.
> You have defined five file registers.
>
> freq_0 ; Register 20 (All register bank 0)
> freq_1 ; Register 21
> freq_2 ; Register 22
> freq_3 ; Register 23
> scratch ; Register 24
>
> All you are doing is to put the constant limit_1 or test_1 into "W" so
> the only thing you should see is the value of "W" being set to the
> constant limit_1 or test_1 As you have defined both of these constants
> to have the value 0xC3 so the value of "W" should become 0xC3 If you
> look at the list file you will see that both movlw instructions
> assemble to 30C3 which is correct. Writing movlw limit_1 or movlw
> test_1 is exactly the same as movlw 0xC3 If you want the value of the
> constant to be put in a file register you need to follow the movlw
> instruction by a movwf instruction.
>
> movlw limit_1 ;Sets the value of "W" to 0xC3
> movwf freq_1 ; moves the value from "W" to register 0x21
> (Which you have given the label freq_1)
>
> If you had not used any names for registers or constants the code
> would be.
> movlw 0xC3
> mofwf 0x21
>
> If you look at the symbol table in the list file you should see
>
> limit_1 000000C3
>
> test_1 000000C3
>
> freq_1 00000021
>
> All the equate statement does is to give a numeric value to a label.
>
> I think using the debugger is just confusing you.
> Les.
> --- In p...@yahoogroups.com, "Jerry O. Stern" wrote:
> >
> > Hi Richard,
> >
> > When you say it worked fine.. Do you mean that during debug when you
> > set breakpoints and looked into the file register contents of
limit_2
> > and mult_1 the register values were the same as the equates?
> >
> > What pic did you setup ... the 84A or 877A?
> >
> > Did you place an include file at the beginning of the asm code or
> > did
> > you put it into the Header file in the Project view window?
> >
> > Did you use a linker file?
> >
> > Thanks for the help
> >
> > jerry
> >
> > -----Original Message-----
> > From: p...@yahoogroups.com [mailto:p...@yahoogroups.com] On
> > Behalf Of rtstofer
> > Sent: Sunday, September 06, 2009 10:33 PM
> > To: p...@yahoogroups.com
> > Subject: [piclist] Re: Help with Equates for a Newbie
> >
> >
> > I just tried it with version 8.36 and it works fine
> >
> > Here is the exact code I used:
> >
> > ; ******************************************************************
> > ; Set up upper frequency limit = 30,000,000 = 0x01C9C380 limit_3 equ
> > 0x01 ; Most significant byte for 30 MHz limit_2 equ 0xC9 ; Next byte
> > limit_1 equ 0xC3 ; Next byte limit_0 equ 0x80 ; Least significant
byte
>
> > ;
> > ******************************************************************
> >
> > ; ****************************************************
> > movlw limit_2
> > ; ****************************************************
> >
> > ; ******************************************************************
> > ; Set up upper frequency limit = 30,000,000 = 0x01C9C380 limit_3 equ
> > 0x01 ; Most significant byte for 30 MHz limit_2 equ 0xC9 ; Next byte
> > limit_1 equ 0xC3 ; Next byte limit_0 equ 0x80 ; Least significant
byte
>
> > ; ; multiplier = 1000000 hz HFO mult_3 equ 0x00 mult_2 equ 0x0F
> > mult_1
>
> > equ 0x42 mult_0 equ 0x40 ;
> > ******************************************************************
> >
> > ; ****************************
> > movlw mult_1
> > ; ****************************
> >
> > end
> >
> >
> > Richard
> >
> >
> >
> >
> > ------------------------------------
> >
> > to unsubscribe, go to http://www.yahoogroups.com and follow the
> > instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )Re: Help with Equates for a Newbie - rtstofer - Sep 8 10:19:52 2009
--- In p...@yahoogroups.com, "Jerry O. Stern"
wrote:
>
> Les,
>
> Many thanks I see where my confusion comes from. In the list (lst) file
> and in the file register window these 'constants' appear at GPR
> addresses (0x20 - 0x7F) equal to their "constant" value. I now see that
> even in places where the constant symbol name replaces what should be
> another variable name from the cblock assignment, that the contents of
> the address correspond to the cblock variable despite the symbol name
> being incorrect. So, it appears to be a MPLAB glitch? I moved up to
> v8.36 but no change in this regards.
Yes, the assembler has always gotten confused in this way. Now I see what you are talking
about.
The assembler looks at literal constants and then tries somehow relate them to internal
registers and things like that. It simply sorts by value.
It doesn't mean that the code is incorrect, it is just the assembler trying to 'help'
you.
Richard
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )