Create Library - Basics

The external libraries are processed through this extra-existing library editor and / or created. The library editor supports the author of a library graphically by overviews and simple choices when creating methods and properties.

The library functions are classically programmed in assembler.

In the source code of the interfaces and modules, functions and macros of the standard library can be used. A external label can imported by .import <label>. The use of functions of other libraries is possible. By using cleverly named constants can be queried whether the Luna programmer has also incorporated the necessary library.

To avoid name collisions, all identifiers must be unique and unambiguous within a library.

It can be used all general Präprozessorfunktionen of Luna assembler as in Inline-Assembler possible, e.g. hi8(), lo8(), shift-commands and so on. In addition, special preprocessor commands are available that make sense only in the creation of libraries (see below).

See also:

Special Präprozessorfunktion(s)

MakeIdentifier( string )

Created from the string passed an identifier (symbol). The string is then no longer considered by the assembler as a string, but as a constant name (symbol). If this constant name already has a value, it can then be used as Such in the assembler source code.

Example

Allocation 0xf0 on the already existing register symbol PORTB. The constant MyPort then refers to the constant (symbol) PORTB so that the value of PORTB is used in the result here.

.set myport = MakeIdentifier("PORTB")
ldi  _HA0,0xf0
sts  myport,_HA0

The following code demonstrates the assigning of a specific port-pin in the Luna-code and the further processing in the assembler source code in an interface.

Luna-Code
Spi.PinMiso = PortB.2
Interface Inline-Method "PinMiso"
.set SpiPinMisoPORT    = MakeIdentifier(NthField({keyword},".",1))
.set SpiPinMisoPortPin	= val(NthField({keyword},".",2))
.set SpiPinMisoDDR		= MakeIdentifier("DDR"+right(NthField({keyword},".",1),1))
.set SpiPinMisoPIN		= MakeIdentifier("PIN"+right(NthField({keyword},".",1),1))
In the Library-Editor

In such assignments which is a bit like word processing. It is the input of the programmer prepared so that you can work on the assembly level useful with the information. The declaration of this inline method in turn ensures that the programmer without receiving an error message that can only enter what he can add to. Here, this is ensured by the regular expression.

In this example, the four constants then contain the following values:

Methods and Inline-Methods

Note

If a real value assignment (no text replacement) used in a method/inline-method, it will displace the first parameter store. That the first parameter will no longer end up in the register block A. The first parameter are stored to the stack like all the other parameters. The register block A is then the value assignment.