User`s manual

178 digi.com Using Assembly Language
11.3.2 Example of Stand-Alone Assembly Code
The stand-alone assembly function foo() can be called from a Dynamic C function.
The entire program can be written in assembly.
11.4 Embedded Assembly Code
When embedded in a C function, assembly code can access arguments and local variables (either auto or
static) by name. Furthermore, the assembly code does not need to manipulate the stack because the
functions prolog and epilog already do so.
11.4.1 The Stack Frame
The purpose and structure of a stack frame should be understood before writing embedded assembly code.
A stack frame is a run-time structure on the stack that provides the storage for all auto variables, function
arguments and the return address for a particular function. If the IX register is used for a frame reference
pointer, the previous value of IX is also kept in the stack frame.
int foo ( int ); // A function prototype can be declared for stand-alone
// assembly functions, which will cause the compiler
// to perform the appropriate type-checking.
main(){
int i,j;
i=1;
j=foo(i);
}
#asm
foo::
...
ld hl,2 // The return value expected by main() is put
ret // in HL just before foo() returns
#endasm
#asm
main::
...
ret
#endasm