Preprocessor (Assembler)

The preprocessor is a part of the Assembler, which prepares the source code for the assemble process.

The following parts will be processed by the preprocessor:

  • dissolve arithmetic and logic expressions with constants.
  • conditional inclusion of sourcecode parts.
  • inclusion of external sourcecode and data files
  • replacing of defined text phrases in the sourcecode.
  • processing of inline functions.
  • processing of macro functions.

Preprocessor functions in the assembler sourcecode

Directives

Command DescriptionExample
.equ create a constant .equ var = 123.45
.set create/assign a constant .set var = 123.45
.def Alias.def temp = R16
.device set the avr controller type.device atmega32
.import import a label.import _myLabel
.importClass1) import avr class. sets all defines and constants of the selected avr controller inclusive .device.importClass atmega32
.importObject2) import a library object .importObject Macro_Delay
.importUsedObjects3) imports all in the source code used libraries objects.importUsedObjects
.cseg select flash segment.cseg
.dseg select sram segment.dseg
.eseg select eeprom segment.eseg
.org Sets the pointer of the actual active segment to a specific value .org intVectorSize
.error Display a error message. Break compile/assemble..error „message“
.warning Display a warning message..warning „message“
.message, .print Display a info message without line number and origin..message „message“
.regisr register a label to a interrupt vector „on the fly“ (used for Library Code).regisr vectorAddress,mylabel
.db (byte) 1 byte each value and strings, data block. 4).db „hello“,0x3b
.dw (word) 2 bytes each value, data block. 5).dw 0x3bda,0xcf01
.dt (triple) 3 bytes each value, data block. 6).dt 0xf0d1a4
.dl (long) 4 bytes each value, data block. 7).dl 0xff01ddca
.bin (file) data block from file byte-wise. 8).bin „filepath“
.odb (byte) 1 byte each value and strings, object data block.odb „hello“,0x3b
.odw (word) 2 bytes each value, object data block. 9).odw 0x3bda,0xcf01
.odt (triple) 3 bytes each value, object data block. 10).odt 0xf0d1a4
.odl (long) 4 bytes each value, object data block. 11).odl 0xff01ddca
.obin (file) data block from file byte-wise. 12).obin „filepath“
.dobjend endmark for object data block with .odb, .odw, … 13))).dobjend label
Example for Object-Datablock
classServiceudpdDatagram:
.odb		"this is a message from the luna udpd server",0x0D,0x0A
.odb		"build with lavrc version ","2013.r6.7",0x0D,0x0A
.odb		0x0D,0x0A
.dobjend	classServiceudpdDatagram

Functions

Preprocessor functions expects only constant parameters.

Functions from the Luna instruction set, depicted in the preprocessor.
  • lo8() resp. low() - Low-Byte of a 16-Bit-value
  • hi8() resp. high() - High-Byte of a 16-Bit-value
  • byte1() - 1. Byte of a 32-Bit-value
  • byte2() - 2. Byte of a 32-Bit-value
  • byte3() - 3. Byte of a 32-Bit-value
  • byte4() - 4. Byte of a 32-Bit-value
  • byte() - Typecasting into an 8-Bit-Integer.
  • word() - Typecasting into a 16-Bit-Integer.
  • integer() - Typecasting into a signed 16-Bit-Integer.
  • long() - Typecasting into a 32-Bit-Integer.
  • longint() - Typecasting into a signed 32-Bit-Integer.
  • int8() - Typecasting into a signed 8-Bit-Integer.
  • int16() - Typecasting into a signed 16-Bit-Integer.
  • int24() - Typecasting into a signed 24-Bit-Integer.
  • int32() - Typecasting into a signed 32-Bit-Integer.
  • uint8() - Typecasting into a 8-Bit-Integer.
  • uint16() - Typecasting into a 16-Bit-Integer.
  • uint24() - Typecasting into a 24-Bit-Integer.
  • uint32() - Typecasting into a 32-Bit-Integer.
  • single() - Typecasting into a signed 32-Bit-Float.
  • float() - Typecasting into a signed 32-Bit-Float.
  • odd() - check wether the value is odd.
  • even() - check wether the value is even.
  • chr() - conversion into binary string (byte).
  • mkb() - conversion into binary string (byte).
  • mki() - conversion into binary string (integer).
  • mkw() - conversion into binary string (word).
  • mkl() - conversion into binary string (long).
  • mks() - conversion into binary string (single).
  • strfill() - fill string with string.
  • hex() - conversion into hexadecimal notation.
  • str() - conversion into decimal notation.
  • bin() - conversion into binary notation.
  • asc() - conversion of the first character of a string into its numeric equivalent.
  • min() - arithmetic function.
  • max() - arithmetic function.
  • format() - formatted, numeric decimal notation.
Special functions, implemented only in the preprocessor.
  • MakeIdentifier() - Ein Symbol aus einem String erstellen.
  • Defined() - check wether there is a constant or a symbol defined.
  • Replace() - Replaces the first occurrence of a string with another string.
  • ReplaceAll() - Replaces all occurrences of a string with another string.
1) , 2) , 3) only used by the compiler
4) , 5) , 6) , 7) , 8) Note: End of block auto-aligned/padding to even address!
9) , 10) , 11) , 12) Note: No auto-alignment/padding
13) Initiates the auto-alignment/padding to even address over the complete data set.