# Application Programs

GNU assembler (for PC and UNIX) or C compiler (for PC and UNIX) can easily be used. For information see the GNU Manual Page. However, other compilers or assemblers for 68,000 may be used as well. To download compiler and assembler use the EyeBot ftp server.

You can either write your own assembly programs or your own C programs to control EyeBot. Your C programs should make use of the EyeBot libraries, which prepares functions for display output (text or graphics), camera input (grayscale or color), sound output, and servo control (motors). Clib functions like "printf" or "getchar" may be used instead of "LCDPutString" and "KEYGet", resp., but please keep in mind that this will link additional library functions and results in a longer executable program.

### How to Create an Application Program

- Take a look at the numerous examples
- You can adapt existing files or create your own
- Please note the file extension convention:

- .c C source program
- .s Assembly source program
- .o object file
- .hex S-record file (ASCII) for download

### Programming in C

Edit the C source file (e.g. demo.c) like the following:

    #include "eyebot.h"
    #include <stdio.h>

    int main ()
    { int k;
      printf("Hello !\n");

      k = KEYGet();
      printf("key %d pressed !\n", k);
      return 0;
    }

- Use the shell script gcc68 for compiling a C program.

- gcc68 demo.c

- Then download the executable to the EyeBot.

- dl a.out

### Programming in Assembly

Edit the assembly source file (e.g. hello.s) like the following:

        .include "labmac.i"
        .section .text
        .globl main

    main:  LEA hello, A0          | load string address
           CALLEXEC LCD_PutString | call assembly routine
           RTS

    hello: .asciz "Hello !"

- Use the shell script gas68 for assembling.

- gas68 hello.s

- Then download the executable to the EyeBot.

- dl a.out

Please note that some gnu assembly conventions differ from the Motorola standard:

- File names end with ".s"
- Comments start with "|"
- If length attribute is missing, "WORD" is assumed
- Prefix "0x" instead of "$" for hexadecimal constants
- Prefix "0b" instead of "%" for binary constants

### Combining C and Assembly Programs

You may combine several C and assembly programs to form a single executable. There are two ways of doing this:

- Use gcc68 with all source files or use gcc68 -c to generate individual object files, which are linked afterwards using gcc68 to build one executable.
- Use a Makefile to compile/assemble/link several source files. Have a look at some example projects or read a Unix documentation to find out details.

Thomas Bräunl, 2001