• Keine Ergebnisse gefunden

Busy Bits

Im Dokument Manual For the HP 9845 (Seite 156-161)

Overlapped processing in the 9845 is partially implemented through the facility of "busy bits".

Each variable located in the BASIC value or common areas has associated with it two bits which are independent of the value - a "read" busy bit, and a "write" busy bit. Each time an I/O operation is executed that cannot be buffered, one of the busy bits is set. If a variable is having its value changed by the I/O operation, then the read busy bit is set. If the variable is output-ting its value in the I/O operation, then its write busy bit is set. If a variable is not involved in a pending I/O operation both bits are cleared. When the I/O operation is completed, the busy bits for the variables involved are cleared.

When an I/O operation is encountered during execution of BASIC statements, the appropriate busy bits are set and a request is made by the operating system for the resources to satisfy the operation. Until that operation is complete, BASIC (in OVERLAP mode), continues to execute succeeding lines in the program until it encounters a statement which contains variables with busy bits that are set.

If the statement is attempting to use the value of a variable and its read busy bit is set, then the further execution of the statement waits until the busy bit is cleared. The same is true for a statement attempting to change the value of a variable when either its read or write busy bit is set. When the I/O operation completes, the busy bits are cleared and the waiting statement is executed.

In short, overlapped processing uses busy bits as a signal as to whether a statement can be executed or not.

If an ICALL statement is executed with overlapped processing, it is possible that a BASIC variable may be "busy" when the routine wants to access it. 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 give the operating system a chance to perform the I/O operation and clear the busy bits.

One way to do this is to exit the ICALL and return to BASIC.

330 ICALL Sort(Busy) 340 IF Busy THEN ~~0

If the Sort routine exits, setting Busy to

a

if a busy condition is not encountered, and to non-zero otherwise, this 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 unsuc-cessful attempt, the operating system is given an opportunity to perform the I I 0 operation which has the variable(s) tied up.

UTiLiTY: Busy

The Busy utility checks the status of the busy bits of a variable.

General Procedure: The utility is given the location of the declaration for the variable. It returns the value of the busy bits for that variable into the A register.

Special Requirements: This utility should be used for all variables involved in overlapped 1/0 operations.

Calling Procedure:

1. Load register B with the address of the pseudo-instruction of the declaration to be checked.

2. Call the utility.

Exit Conditions: The utility returns the busy bits in the A register. The "read" busy bit is in bit

a

and the "write" busy bit is in bit 1. The other bits are cleared.

In the following example, if any of the busy bits among three common variables is set, a flag is set and the routine is exited

-ISOU~~E Busy bits: INT ISOUPCE

I:::;OUF-:CE ISCDJPCE I:::;OUPCE ISOUF.:CE I:::;OURCE I::;OUPCE

LItH

=

\,i.::u·-· i .3. b 1 E" 1 T::;j'1 Btt::.~/

r;::ZA Is bu ::;.::.-' LIfE: =ivl.~r· i .:it: 1 E'2 .J:;!'! Bu::;.':.-' F.:ZA 1.:= . . bt~==.i.}

Llit; =\:~f-·i.3.tll E':3

LDA

==i

LIlB = Bu::;.:=--,_ bit ::;.

J::;N Fut l·)a 1 tiE"

~:ET 1

ISC)URCE Go .3.hE".3.d: ! Contint~E" pr-·c,cE"ssin':;l.

I SOUF.:CE L'!or--k: ! Cont i nUE" pt~oc E":::·S i ng

The overhead of exiting and re-entering the ICALL statement while waiting for a variable to become unbusy can be avoided. It is sufficient to allow the operating system to perform an I I 0

operation without having to go back to BASIC. A special utility, To_system, is provided for this purpose.

UTILITY : To_system

The To_system utility gives the operating system a chance to move toward completion of any I I 0 operation which has not already completed.

General Procedure: Each call to the utility gives the operating system one chance to perform an 1/0 operation.

Calling Procedure: Call the utility.

Exit Conditions: The utility always returns the instruction following the JSM To_system in-struction. There are no error exits from the utility.

In the following example, the Sort routine waits until all busy hits in the three common vari-abIes are cleared before proceeding with execution:

~:; C)~j F.~ C: E

~=;CiJJ~~C:E 1:/·3.;--1:

:=;i]~JF:~C~E

~:;Cltl~:C:E

:::;OUPCE SOURCE

SOURCE

C:Cit~1 It·~T

SHO FEL

PZA 1:::- btE::--'

LICB =\'~~i-'2

.J::::trl E;t~=.~: .. i SZA Go ahe-3.d

¥J~=;r1; T

c-:-

:=-:):::. t E"f(§ Allow :::ystem to do some C: ~-~E' c k t;tJ ::-:) CI i t:=- o::i.g=:t. i t-j :I

Continue processing.

-: .. ~-,

1··' 8_lu

Chapter 7

I/O Handling

Summary: This manual should be used in conjunction with "BASIC Language Inter-facing Concepts" which covers the specifics of different interface cards. This chapter describes the various techniques of handling the receiving and sending of information to peripherai devices. Topics are: a review of I/O machine instructions, registers, applica-ble utilities, interrupts and interrupt service routines, handshake I/O, direct memory access, and mass storage devices.

A major usage for assembly language programs is to improve or customize the performance of the 9845 with respect to data transfers with peripheral devices. The types of devices dealt with are those which communicate via the various interface cards (e.g., HP 98032, HPIB, etc.). The types of 1/0 which the assembly language supports are programmed (handshake-type), inter-rupt, and direct memory access (or DMA).

A number of detailed examples have been provided demonstrating the various types of 1/0 using different interfaces. These examples can be found in Appendix H.

Im Dokument Manual For the HP 9845 (Seite 156-161)