next up previous contents
Next: 14.1.1 Declaring Variables in Up: 14 Binary Programs Previous: 14 Binary Programs

14.1 The Binary Source File

Special keywords in the source assembly language file (or module) are used to establish the following features of the binary program:

Entry point.
The entry point for calls to each program defined in the binary file.

Initialization entry point.
Each file may have one routine that is called automatically upon a reset condition. (The reset conditions are explained in Section 5.3, which discusses global variable initialization.) This initialization routine particularly useful for programs which will function as interrupt routines.

C variable definitions.
Any number of two-byte C integer variables may be declared within a binary file. When the module is loaded into IC , these variables become defined as globals in C.

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.





next up previous contents
Next: 14.1.1 Declaring Variables in Up: 14 Binary Programs Previous: 14 Binary Programs



Fred G. Martin
Fri Mar 29 17:44:15 EST 1996