.TITLE TYPBUF .IDENT /30MY89/ ; Last Edit: 17-JUL-1989 10:55:17 ; File: [22,310]TYPBUF.MAC ; History: ; 30-May-89. Philip Hannay. Created from PAS 1.2 TYPBUF. ; 17-Jul-89. Philip Hannay. Changed QIO to use efn 24, which ; is reserved for P3UTIL use. .REM | FUNCTION TYPBUF(LUN:integer):INTEGER; EXTERNAL; { *USER* The TYPBUF function returns the current character count in the typeahead buffer of the specified lun number in LUN. Naturally, the lun must be assigned to a device that has typeahead enabled (like a terminal with TYPEAHEAD), and the device must be attached. A zero or positive integer returned as the value of TYPBUF will be the current character count. A negative integer will be returned if the lun specified is not a "typeahead" device. The negative value will be a directive error code or an IO error code. This routine uses local efn 24, which is reserved for P3UITL use. *ERROR CODES* A returned negative value is either a directive error or an IO error code resulting from the QIOW SF.GMC call. Common errors would be: .lit -7 (IE.DNA) device not attached -15 (IE.ABO) request terminated - invalid device or no typeahead -96 (IE.ILU) invalid lun number *WIZARD* Typeahead count is retrieved using the QIOW SF.GMC function, specifying the TC.TBF characteristic code. } | ; ; assemble with PASMAC.MAC. ; FUNC TYPBUF,COUNT,2 PARAM LUN,INTEGER VAR BUF,INTEGER VAR IOSB,INTEGER*2 SAVE BEGIN .MCALL QIOW$S MOV #TC.TBF,BUF(SP) ;REQUEST TYPE GOES IN LOW BYTE OF VARIABLE ;HIGH BYTE OF VARIABLE IS ZERO -- THIS IS ;WHERE THE BUFFER CHAR COUNT WILL APPEAR MOV SP,R1 ;CREATE POINTER TO BUFFER AREA ADD #BUF,R1 ; IN R1 MOV LUN(SP),R0 ;PUT LUN NUMBER IN R0 MOV SP,R2 ;CREATE POINTER TO IO STATUS AREA ADD #IOSB,R2 ; IN R2 QIOW$S #SF.GMC,R0,#24.,,R2,, ;ISSUE QIO FOR TYPEAHEAD BUFFER COUNT BCC 1$ ;BRANCH IF NO DIRECTIVE ERROR MOV $DSW,BUF(SP) ;SAVE DIR ERROR BR 2$ 1$: CMPB #IS.SUC,(R2) ;SEE IF QIO WAS SUCCESSFUL BEQ 3$ ;BRANCH IF SUCCESSFUL BIS #^O177400,(R2) ;EXTEND SIGN TO CONVERT IO ERROR BYTE TO WORD MOV (R2),BUF(SP) ;SAVE IO ERROR BR 2$ 3$: CLRB BUF(SP) ;MAKE SURE LOW BYTE IS CLEAR SWAB BUF(SP) ;THEN BRING COUNT INTO LOW BYTE 2$: MOV BUF(SP),COUNT(SP) ;RETURN RESULT TO CALLER ENDPR .END