Special keywords in the source assembly language file (or module) are used to establish the following features of the binary program:
To explain how these features work, let's look at a sample IC binary source program, listed in Figure 2.
Figure 2: Sample IC
Binary Source File: testicb.asm
The first statement of the file (`` ORG MAIN_START'') declares the start of the binary programs. This line must precede the code itself itself.
The entry point for a program to be called from C is declared with a special form beginning with the text subroutine_. In this case, the name of the binary program is double, so the label is named subroutine_double. As the comment indicates, this is a program that will double the value of the argument passed to it.
When the binary program is called from C, it is passed one integer argument. This argument is placed in the 6811's D register (also known as the ``Double Accumulator'') before the binary code is called.
The double program doubles the number in the D register. The ASLD instruction ( ``Arithmetic Shift Left Double [Accumulator]'') is equivalent to multiplying by 2; hence this doubles the number in the D register.
The RTS instruction is ``Return from Subroutine.'' All binary programs must exit using this instruction. When a binary program exits, the value in the D register is the return value to C. Thus, the double program doubles its C argument and returns it to C.