Executing Cheops Programs

This document reviews the different ways to run programs compiled to run on Cheops from any host platform. To learn about the conventions of compiling programs and libraries for Cheops see Compiling Code for Cheops.

In depth usage and descriptions of Chex and Chterm may be found in Chex Details, and Chterm Usage. This document intends only to compare and contrast the different modes of program execution on Cheops.

Executable format

The template Makefile for Cheops local binaries produces two different executable files. These files are loaded into Cheops memory by the three different loader programs discussed in the document. The two executable file types are relocatable and fixed.

Relocatable Binary

The name of an application's relocatable binary file is defined by the value of the BINFILE variable defined in the application's Makefile. All function and variable addresses of the relocatable file are relative to the first address of that executable itself. Thus the main() function is always referenced as address zero.

Fixed Binary

The name of the application's fixed binary file is the same as that of the relocatable, but with an added.t extension. All addresses of the fixed file are set relative to the value following -Ttext in the Makefile's FIXED variable. Thus the given address becomes the address of main(). All other functions will occupy consecutive addresses after main(). Uninitialized variables may be placed elsewhere using the -Tdata option (refer to GNU/960 Tools: gld960 Usage).

NOTE: Since the span of addresses must be guaranteed to not conflict with any other program, use of fixed type executables is of limited utility and its use is discouraged for non-system programmers. It is covered in this document for completeness, not as an invitation for daily use.


Chex

Chex stands for Cheops execute. This is a host program that downloads both relocatable and fixed programs at a rate of approx. a megabyte per second into Cheops memory and then maintains a SCSI communications channel to handle UNIX system call requests made by the Cheops client. This is the preferred method of executing Cheops programs. Refer to Chex Details for more information on this utility.


Chload

Chload loads any binary file into a given address on Cheops via SCSI. One parameter describes the file type: "regular" or "executable". If the file type is regular, the file is simply written in its entirety into Cheops local memory. If described to be of type executable, the file must be a fixed .t file (described above).

NOTE: Chload may not be used to SCSI download a relocatable program.

Usage:

     chload < file>   ("reg" | "exe") < hex address>
	[-pid < process_number> ]

If the download address matches the -Ttext option used to create the .t file, Chload does whatever preprocessing is required (byte ordering to little endian for cheops and removing the b.out header) before loading it down into Cheops local memory over SCSI.

Chload uses no SCSI-based interprocess communications with the Magic7 operating system before or after program initiation. Therefore, to start execution on the downloaded program, the following initiation commands must explicitly be given to Magic7 via the serial console program, chterm (see Chterm Usage):

sp < pid>
pick an unused process slot and `start process' to initialize it.
cr < pid>
set the `code return' address for the given process. this command will then prompt you for address of the first executable line of code. This should match the -Ttext fixed address described above.
rs < pid> [params]
`restart the process' to actually begin execution. if optional command line parameters are given, these will be given to the argc,argv variables of the program's main() function.

Once the program is loaded, these Magic7 commands may be used any number of times to restart the program with different command line arguments.

WARNING: variables initialized at declaration and static variables assumed to be set to zero will not be properly initialized. They will retain the same values as they did when the program last terminated.

If given the -pid option, Chload will echo the appropriate Magic7 commands which can be typed or pasted into your Chterm window to execute the program.


Chterm

Chterm may also be used to download and execute a fixed executable program. However, this approach is much more time consuming, since the download is done over the Cheops serial port (generally at 9600 baud.) This may be done by using the following Magic7 monitor commands from the Chterm serial console program:

do < pid>
'download' a fixed program to be referenced by the given process number. This command will then wait for an key. This is a signal to Chterm to prompt for the path name of the fixed executable and then start the serial download. The `start process' and `code return' commands required when using Chload are automatically done by the `download' command.
rs < pid> [params]
`restart the process' to actually begin execution. if optional command line parameters are given, these will be given to the argc,argv variables of the program's main() function.

Refer to Chterm Usage for more information on this utility.

NOTE: Chterm may not be used to serial download a relocatable program.


Jump to Software Tools
Jump to the Cheops Homepage
cheops-web@media.mit.edu
This is a "fix it yourself" page, located at /mas/garden/cheops/WWW/software/executing_code.html