AVR Assembler 1.73 - Warning caused of redefinition of regi

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I got problems with the new Assembler 1.73. I redefine registers like R23 with the command .DEF in subroutines and get warnings like "Register already defined by the .DEF directive". In the old version 1.3 the warnings doesn't exist. is there any possibility to switch of the warnings or to change the code. I got more than 30 Warnings!!! And don't find errors in the notification when one occurs!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I use 1.30, no problems. Can be a bug.

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

doe you not need to use set for redifining a reg
maybe I'm wrong

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

The second noname is correct. Use ".set" instead of ".def". You might want to download a copy of the AVR Assembler User Guide found here:

http://www.atmel.com/dyn/resourc...

This document does not cover all the new features of 1.73 (at least it didn't a week or so ago) but will cover .def and .set. Read it.

Regards,
Steve

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Marc:

.equ and .set will define constant(s, associate a value with a name),
.set will allow a re-allocation of the value to the same name during run-time, with .equ the value can't be redefined.

.def associates a (physical) register with a name, e.g. .def r23=temp -> use the name 'temp' instead of 'r23': 'ldi temp,3' will be the same as 'ldi r23,3'.

".equ/.set" and ".def" are different animals.

Talking about .DEF: If you use

.def r23,temp1
.def r23,temp2

the assembler will issue a warning ("... already used ..."), this is standard behaviour for versions 1.3 as well as for 1.73.

Even though you receive this warning, your source code can utilize both names (temp1 and temp2 in the example) to refer to the same register, r23 - or, in other words, multiple register definitions may be used. As several different names may actually specify the same physical register, IMHO the warning given is correct - watch your pushs and pops and whatever else your code is doing when you do this - you'll be walking on thin ice ...

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What exactly is the syntax you guys are talking about for redefining a register with .SET? The following won't work

.def MoveCount = r25
.set MyTest = r25

neither will this:

.def MoveCount = r25
.set MyTest = MoveCount

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

.set is used to assign a numeric value to a name. A register is not a numeric value.

Your first example is bad because it attempts to use .set to assign a name to a register.

Your second example is invalid because it attempts to assign a register to MyTest.

Why not just .def MyTest = r25 ??

You CAN have more than one name assigned to a register, I think, though its dangerous.

What are you trying to do? Are you trying to name the register or are you trying to "put" a value into the register? If its the latter, you have to do it with a mov or ldi.

Jim

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanx for all the help!

To Jim/Sally: I use .def to define "local variables" in subroutines. So I have to define shared registers in more than one subroutine for the same register like

.def MyTest = r25
..
.
.def MyTest = r25

To Steve: Instead of the example above I can write

.set MyTest = 0x25
..
.
.set MyTest = 0x25

This cause no warnings but several commands like mov or clr don't work!

To Andreas:
I think the same as you. And i'm sure that I walk on thin Ice, but I have to. I only want to avoid the warnings to find get a simple notification after compiling.

To Noname:
Your right in version 1.30 there are no warnings like this!

Marc

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The example show that you assign the same name twice to one register, is that true for your application as well? In that case, it should be enough to assign the name once. I performed a small test which suggests that one .def is enough, even if it is at the very bottom of the source, or in the last included asm-file.

If you're using different names for one register I would join the club and caution you against that.

-Geir

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry Geir - copy and paste error. The right example:

def MyTest = r25
..
.
.def Another_Test = r25

.set MyTest = 0x25
..
.
.set Another_Test = 0x25

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Your basic problem is that MyTest and Another_Test are defined as names of registers. In fact, you have given r25 two names. They both occupy the same register. If you save something in MyTest, Another_Test will have the same value.

0x25 is not the same as r25. Are you trying to put a value into the register?

You CANNOT give these registers values with a .SET. You must use LDI or MOV.

Jim