assembler directives

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

What's the difference between these directives?

.DEF = ...
.EQU = ...

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

Well the user manual says:

Quote:
The DEF directive allows the registers to be referred to through symbols. A defined symbol can be used in the rest of the program to refer to the register it is assigned to. A register can have several symbolic names attached to it. A symbol can be redefined later in the program.

Quote:
The EQU directive assigns a value to a label. This label can then be used in later expressions. A label assigned to a value by the EQU directive is a constant and can not be changed or redefined.

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

You can define a register.

.def temp = r16

You can define a bit names.

.equ msb = 7
.equ lsb = 0

Then you can do something like.

sbrc temp, msb ;instead of sbrc r16, 7

Makes codes/routines more readable.
Check the device definition (*.inc) files. Atmel already defined all features of the particularly AVR.

RES

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

Thanks, I didn't realize this was all in one of the help files for avrstudio.