Previous page Next page Navigation bar

Programs

Linkage Conventions

A linkage convention is a set of rules for passing arguments and the flow of control to subprograms and receiving values and the flow of control back from subprograms. The FX-7400G and CFX-9850G calculators impose a standard linkage convention through the “Prog” construct, which transfers control to another program, and through the convention of control returning to the caller when either the end of the called program or the “Return” construct is executed. However, the FX-7400G and CFX-9850G calculators also have a single set of variables shared among all programs. This implies that any subprogram must be aware of the variable use of all calling programs, to ensure it does not accidentally destroy a variable upon which a caller depends.

The programs in this site use a discipline that permits each program to effectively have its own set of local variables. The Variable Save and Restore routines construct a variable save stack using the Z variable and the List 6 list, save variable contents to that stack, and restore variable contents from that stack. This permits a program to save a range of variables on routine entry, use them without regard for their former contents, and restore them on routine exit. The program’s use of the variables is transparent to calling programs.

The variable save and restore routines do not protect variables A through E. These variables are reserved for inter-program communication. Values passed to subprograms and values returned by the subprograms are stored in these variables. Arguments to the called program are assigned to variables sequentially starting with variable A. Results from the called program are frequently assigned to variables sequentially starting with the first variable not used for arguments to the called program. Other arrangements for return values may occur; the calling sequence for each program is documented with the program. All variables A through E are available for use by the called program: any use of the “Prog” construct must be assumed to destroy the contents of all variables A through E.

The called program must preserve other variables, or at a minimum must document its use of other variables.

[ Previous page | Top of page | Next page ]

Previous page Top of page Next page Navigation bar

Copyright © 2002 Brian Hetrick
Page last updated 19 May 2002.

Brian’s Casio Calculator Corner

Home

Programs

Index

Linkage Conventions

Mathematics

Finance

Physics

Utility

Tutorial

Puzzles

Site Information

Your Privacy

Site Map

E-mail

Site Technical Data