Help with Equates for a Newbie

Started by jsternmd September 6, 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

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..., "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
>
----- Original Message -----
From: g8fub
To: p...
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

----- Original Message -----
From: leon Heller
To: p...
Sent: Sunday, September 06, 2009 6:00 PM
Subject: Re: [piclist] Re: Help with Equates for a Newbie
----- Original Message -----
From: g8fub
To: p...
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

<*>[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... [mailto:p...] On Behalf
Of g8fub
Sent: Sunday, September 06, 2009 12:50 PM
To: p...
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..., "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
What assembler are you using?

The constants work fine under MPLAB 8.01

Richard
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..., "Jerry O. Stern" wrote:
>
> Hi Les,
>
> Look at these two:
>
> One works one doesn't
>
> 73 Jerry
> K1JOS
>
> -----Original Message-----
> From: p... [mailto:p...] On Behalf
> Of g8fub
> Sent: Sunday, September 06, 2009 12:50 PM
> To: p...
> 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..., "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
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

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... [mailto:p...] On Behalf
Of g8fub
Sent: Sunday, September 06, 2009 6:31 PM
To: p...
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..., "Jerry O. Stern" wrote:
>
> Hi Les,
>
> Look at these two:
>
> One works one doesn't
>
> 73 Jerry
> K1JOS
>
> -----Original Message-----
> From: p... [mailto:p...] On
> Behalf Of g8fub
> Sent: Sunday, September 06, 2009 12:50 PM
> To: p...
> 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..., "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
I am using 8.33... I will switch to 8.01 on a different PC and give it a
try.

-----Original Message-----
From: p... [mailto:p...] On Behalf
Of rtstofer
Sent: Sunday, September 06, 2009 5:48 PM
To: p...
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