Writing Functions Through the HP Palmtop's API
Some basic guidelines need to be followed when writing effective functions:
- All functions must be declared Far.
- Parameters on the stack are at a displacement of 18 bytes from usual.
- On entry the data structure, DS, is the System Manager's DS. The function must not
modify the System Manager's DS on exit. If the function needs to return a modified DS,
the function should replace the saved DS on the stack at a displacement of bp + 10 from
the function entry point.
- Functions must save registers suitably, depending on the calling interface.
- Microsoft C version 6.0 and 7.0 require SI, DI, SS, DS, and BP to be saved.
- The flags registers are automatically saved. Note that the dispatching
mechanism guarantees that the direction flag is cleared on entry (the forward direction
is set on).
- Although parameter passing in registers is not recommended, parameters may be passed in
registers, except for the AX register, which holds the Class/Function number.