Script for Laboratory: Designing embedded ASIPs - CES
Script for Laboratory: Designing embedded ASIPs - CES
Script for Laboratory: Designing embedded ASIPs - CES
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
nop<br />
nop<br />
...<br />
; The r1 and r2 will be replaced by<br />
; the used registers <strong>for</strong> those parameters. The r3 referrs<br />
; to the register <strong>for</strong> the return value.<br />
The asm directive to create inline assembly is CoSy specific and so it won’t compile e.g. with<br />
gcc. To write a C-Code, that can be used with gcc and with CoSy and that also includes CoSy<br />
specific inline assembly, one can use a “#ifdef COSY … #else … #endif” constructions<br />
to handle a gcc-version and a CoSy-version in the same file. As explained in Chapter<br />
8.3, a “#define COSY” directive is automatically added to the source code, if it is<br />
compiled with the mkimg script. To use inline assembly with the CoSy compiled version and<br />
an equivalent function call with the gcc-compiled version one can write something like:<br />
#ifdef COSY<br />
asm int example(int parameter1, int parameter2)<br />
{<br />
; ...<br />
}<br />
#else<br />
int example(int parameter1, int parameter2)<br />
{<br />
// ...<br />
}<br />
#endif<br />
The most important directives are explained in Figure 8-3. They concern restrictions to the<br />
parameters and reservations of further registers.<br />
Directive Explanation<br />
.scratch<br />
With this directive temporary registers can be requested. For example:<br />
.scratch temp1, temp2<br />
would reserve 2 registers which you can address in the assembly code as<br />
@{temp1} and @{temp2}. For every scratch register you need a restrict<br />
directive (see below). The name of a scratch register needs to be at least 2<br />
characters long.<br />
- 78 -