HARSFEN0602ElmoHARmonicaSoftwareManual

PRELIMINARYDRAFT

5 The Harmonica User Programming Language

This chapter describes the Harmonica user language in detail.

This chapter is somewhat out of place, since the user program language is not really a feature of the Harmonica.

The Harmonica can only understand virtual assembly commands – see commands at the chapter The Virtual Machines: Short reference.

The Compiler translates user language into virtual assembly commands. It reads user program and transforms it to the sequence of simple virtual assembly commands. The compilation process runs off-line in the PC, not inside the Harmonica. Before the Harmonica executes a user program, it must be preliminarily compiled and the compiled code must be downloaded to the serial flash of the Harmonica. A little more about the Compiler see at the section Compilation

An Amplifier program is a list of commands in certain order. A user program can be anything from a simple list of commands to a very complicated machine management algorithm.

The section below describes how to write, maintain, and run user programs for the Amplifier.

5.1User Program Organization

A user program is organized as follows:

Integer and floating point variable declarations

Program text, including expressions, commands, labels, and comments

An exit directive may be used to terminate the program.

Most of the interpreter commands can be used in the program text. In order to learn if a given interpreter command can be used in a program, please refer the scope attribute of that command in the Command Reference Manual.

The Interpreter commands that cannot be used in a program are:

Commands that upload or download data between the Amplifier and its host.

Commands that store data in the flash memory, or that retrieve data from the flash memory.

Commands concerning the execution of the user program.

In addition to the interpreter commands, a program may include program flow statements that manage how the program runs.

Iterations.

Subroutine execution commands.

Conditions.

In the program text, semicolons, commas, line feeds or carriage returns separate the commands.

A single program line is executed as a one unit, preventing intervention from the interpreter or a CAN command.

For example in the sequence UM=5;

MO=1;

It is possible that an interpreter command shall be executed between the execution of the two program statements. If the interpreter statement was UM=2, then MO=1 is specified for a wrong unit mode. The sequence

MO=0;UM=5;MO=1;BG

Guarantees that MO=1 is executed with the correct unit mode.

Example 1:

int x,k;

Variable declarations

##Foo

Label definition

28

Page 30
Image 30
Elmo HARmonica, HARSFEN0602 software manual Harmonica User Programming Language, User Program Organization