hewlett-packard HP 9835A — 130

130 Communication Between BASIC and Assembly Language If an ICALL statement is executed with overlapped processing, it is possible that a BASIC variable in the common area may be "busy" when the routine wants to access it. (The busy bits of variables passed as arguments are checked - and are non-busy - before the ICALL is executed.) Although it is 'still possible to access the variable without regard to the status of the busy bits, frequently that is not a desirable programming approach. You may on occasion want to check the value of the busy bits when you suspect the user of. the routine may be using overlapped processing.

Busy bits are checked from an assembly program using the "Busy" utility to be described shortly. If you are checking the bits for a busy condition, and the busy condition is set, it remains set throughout the time you are in the assembly routine. For it to become un-busy, you must exit the routine and permit the operating system a chance to perform the 1/0 operation and clear the busy bits. For example - 340 IF Bus) THEN 330 If the Sort routine exits, setting Busy to 0 if a busy condition is not encountered, and to non-zero otherwise, this is a tight loop which keeps trying to execute Sort until the common variables which are busy become un-busy and it can proceed on its way.

By exiting the routine after each unsuccessful attempt, the operating system is given an opportunity to perform the 110 operation which has the variable(s) tied up. UTILITY: Busy The Busy utility checks the status of the busy bits of a variable in BASIC's common area. It is not necessary to check the busy bits of a variable passed as an argument since all arguments are checked upon calling a routine (and the call is executed only when all the arguments are not busy). General Procedure: The utility is given the location of the common declaration for the vari- able. It returns the value1(}f the busy bits for that variable into the A register. Special Requirements:

This utility should only be used for variables in common.