AN3349
Application note
eTPU assembly converter
Introduction
The eTPU assembly converter is a tool used to convert Byte Craft eTPU assembly code for
SPC563Mxx and SPC564Axx devices to eTPU compiler assembly code. The tool can be
used either to convert specific instructions manually or to convert entire .asm files, .c files or
directories. The tool only converts assembly instructions (either in .asm files or in inline
assembly sections in c files). With this tool it is possible to easily convert files which were
previously compiled in Byte Craft to the new compiler for eTPU.
September 2013
Doc ID 018511 Rev 2
1/13
www.st.com
Contents
AN3349
Contents
1
2
Command line options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Convert mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1
Convert mode-language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.1.1
2.1.2
Assembly mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
C mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2
Convert mode-input type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2.1
2.2.2
Manual mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Directory/file mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3
Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3.1
2.3.2
2.3.3
2.3.4
Manual assembly mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Manual C mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
File assembly mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
File C mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3
Converter options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.1
3.2
3.3
No warnings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Preprocessing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Debug information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4
Converter operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.1
4.2
4.3
4.4
Context . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Error handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Parallel instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
5
Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5.1
5.2
5.3
5.4
5.5
5.6
Complex expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Negative numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Byte Craft errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Unsupported features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Parallel instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11
2/13
Doc ID 018511 Rev 2
AN3349
Contents
5.7
Warnings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11
5.7.1
5.7.2
ld/ldm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Hex directives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
6
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Doc ID 018511 Rev 2
3/13
Command line options
AN3349
1
Command line options
The following usage appears when running the converter with the
-h
switch. A detailed
explanation appears in the sub sections below.
etpu_asm_converter [-options] (-c <file> | -a <file> | -m | -mc)
Convert modes (exactly one of the following flags must appear):
●
●
●
●
-m:
manual mode, converts assembly instructions from stdin.
-mc:
manual mode, converts c text from stdin.
-c <c_file>
[out_file]:
converts all assembly code in <c_file>.
-a <asm_file> [out_file]:
converts the assembly file <asm_file>.
-nowarn:
suppress warnings
-h:
display usage message
-pp:
preprocess. Replaces macros in assembly sections before converting.
-debugE:
debug errors. When this option is used more information is printed if errors
occur (please note this option was created for developing purposes, the information
refers to lex token names and isn't always helpful).
Options (if used, must appear before convert mode):
●
●
●
●
4/13
Doc ID 018511 Rev 2
AN3349
Convert mode
2
Convert mode
The converter can run either in manual mode (-m,
-mc),
or in directory/file mode (-c,
-a).
In
both modes, the converter can run in assembly mode (-a,
-m)
or c mode (-c,
-mc).
2.1
2.1.1
Convert mode-language
Assembly mode
In assembly mode (-a,
-m)
the entire file (or manually inserted input) will be treated as Byte
Craft assembly and converted immediately.
2.1.2
C mode
In c mode (-c,
-mc)
the entire file (or manually inserted input) will be treated as a c
language file. The file will be copied line by line and only the inline assembly instructions will
be converted. Inline assembly instructions in Byte Craft begin with the
#asm
directive and
end with
#endasm
directive. One line inline assembly instructions in Byte Craft can also
begin with the
#asm
directive and an open parenthesis and end with a closing parenthesis.
2.2
2.2.1
Convert mode-input type
Manual mode
In manual mode (-m,
-mc)
the user inserts text manually to the standard input and the
converter prints the converted text to the standard output. This mode is useful in order to
check specific instructions. Notice that the output is usually printed only after a full
instruction has been analyzed (including the ending '.' character which is essential in Byte
Craft).
2.2.2
Directory/file mode
When the converter runs in directory/file mode (-a,
-c)
a specific file or directory must be
specified right after the
-c
or
-a
mode switch.
If the argument after the mode switch is a directory, the converter converts all the files in the
specified directory which end with the
.c
extension (if the switch was
-c)
or the
.asm
extension (if the switch was
-a).
Each generated file will be named
<file_name>.converted.c
or
<file_name>.converted.asm
depending on the current
language mode.
If the argument after the mode switch is a file (and not a directory) the specified file will be
converted. In this case another argument may appear right after the file name to specify the
name of the new generated converted file. If such an argument does not appear the new file
will be called
<file_name>.converted.c
or
<file_name>.converted.asm
depending
on the working language mode.
Doc ID 018511 Rev 2
5/13