7.1 Functions

Functions defined for the assembler.

  • LOW(expression) returns the low byte of an expression
  • HIGH(expression) returns the second byte of an expression
  • BYTE2(expression) is the same function as HIGH
  • BYTE3(expression) returns the third byte of an expression
  • BYTE4(expression) returns the fourth byte of an expression
  • LWRD(expression) returns bits 0-15 of an expression
  • HWRD(expression) returns bits 16-31 of an expression
  • PAGE(expression) returns bits 16-21 of an expression
  • EXP2(expression) returns 2 to the power of expression
  • LOG2(expression) returns the integer part of log2(expression)
  • INT(expression) Truncates a floating point expression to integer (i.e. discards fractional part)
  • FRAC(expression) Extracts fractional part of a floating point expression (i.e. discards integer part).
  • Q7(expression) Converts a fractional floating point expression to a form suitable for the FMUL/FMULU/FMULSU instructions (see also http://ww1.microchip.com/downloads/en/devicedoc/atmel-0856-avr-instruction-set-manual.pdf). (Sign + 7-bit fraction.)
  • Q15(expression) Converts a fractional floating point expression to a form suitable for the FMUL/FMULU/FMULSU instructions (see also http://ww1.microchip.com/downloads/en/devicedoc/atmel-0856-avr-instruction-set-manual.pdf). (Sign +15-bit fraction.)
  • ABS() Returns the absolute value of a constant expression
  • DEFINED(symbol). Returns true if symbol is previously defined using .equ/.set/.def directives. Normally used in conjunction with .if directives (.if defined(foo)), but may be used in any context. It differs from other functions in that parentheses around its argument are not required, and that it only makes sense to use a single symbol as argument.
  • STRLEN(string) Returns the length of a string constant, in bytes