As stated earlier, when programming the MC68332, the program designer
does not need to worry about the specific op-codes for the CPU. The
programmer has a choice of programming in 'Assembly' code or in a
higher level language like C. For laboratory three, you will do the
first option and program the instructions in assembly code. Assembly
code source files have a .s extension.
Each CPU32 instruction has the following: an operation code determining
the operation to be performed, a designation of the length of the
operand or operands, and specifications of the locations of any operands
involved by indicating an addressing mode for each operation. For
example, the instruction
will add two 16-bit operands, where X and Y designate
the locations of the operands. Here is a simple hello.s
Compiling a Program
After creating an assembly source file with a text editor, the following
steps are performed before the program can be executed by the CPU32.
First, the assembly source code is translated by the assembler,
which (if the code is free of errors) produces an object module
(.o extension). Once the object module is produced, it must be further
processed into a load module. For the Eyebot, the load modules
have a .hex extension.
If there are many object modules to be combined into one program,
a development program called a linker is required to combine
the objects into a single load module.
There are some simple examples of assembly code for the MC68332 here.
(Note: After following the link, click 'Controller' -> 'Example
Progs' -> 'asm')
Notice at the top of the example program 'hello.s'
there are the three statements
The .include statement specifies an assembly header file (like a
.h file for C modules) which allows the LCD_PutString
statement to be executed. The .section statement specifies the starting
memory location to store the program. Finally the .global statement
allows the 'main' function to be executed by the operating system.
For laboratory three, make sure and include these statements at the
top of your .s file.
The eyebot.i assembly header file
will allow a variety of commands which will be needed for laboratory
three. I suggest you look at this file to see what is available.