Jump to content
Sign in to follow this  
apfei01

Assigning 2 variables to one address

Recommended Posts

The following short code will compile/assemble wrong:

 

#pragma CLOCK_FREQ 20000000

 

// Define device config block

asm {

list p=16F628

__config H'3FFE' ;UNPROTECT&HS&WDTEN&PWRTDIS&BOREN&LVPEN&DUNPROT&WRTEN&DEBU

GDIS

}

 

unsigned char var_a;

unsigned char var_b@var_a;  // assign var_b to the same address like var_a

 

void main () {

}

 

The .lst-file looks like that:

 

                    00004         ;Variables *****************************************

 00000070            00005 _var_a                          equ 0x70 ;1

 00000000            00006 _var_b                          equ 0x00 ;1                <--- should be 0x70 too

0000                  00007         ORG 0

 

Is it a bug or misunderstanding? How to overcome?

 

Using: C2C-Compiler 5.4e

Share this post


Link to post
Share on other sites
Guest Pavel

This is not a bug. The second variable declaration doesn't make sence. A fixed address must be a number.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

Sorry, but I do not agree:

 

1/

I try to use the floating point libraries provided by MicroChip. In the header file they assign - let's say - AARGB7 to 0x20 as well as ACCB7. There's also an application note available to embedd the librariers into C. (see AN669; well, I know they don't use C2C)

 

2/

So when this is not a bug and the statement makes no sense, why there's no error/warning generated?

 

3/

Defining the variable/address overlap with #define - statements makes the code hard to debug in case of a problem. Changing the library code is time consuming ...

 

4/

Maybe you can handle this as a feature request?

Share this post


Link to post
Share on other sites
Guest Pavel
Sorry, but I do not agree:

 

1/

I try to use the floating point libraries provided by MicroChip. In the header file they assign - let's say - AARGB7 to 0x20 as well as ACCB7. There's also an application note available to embedd the librariers into C. (see AN669; well, I know they don't use C2C)

If you need to place several variables on the same memory location set the location for every such variable:

 

char v1@0x20;

char v2@0x20;

 

2/

So when this is not a bug and the statement makes no sense, why there's no error/warning generated?

Compiler should benerate an error message. This is a compiler bug.

 

3/

Defining the variable/address overlap with #define - statements makes the code hard to debug in case of a problem. Changing the library code is time consuming ...

 

4/

Maybe you can handle this as a feature request?

Yes this may be a nice new feature. And the syntax looks right. I will add it to my todo list for the new compiler.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

Pavel,

 

thanks for the answers and the the quick response. I've choosen your suggested "workaround" and the code is partly running ...

 

73, Andy.

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...