2 ;******************* START OF SPECIFICATIONS ***********************************
4 ; MODULE NAME: PRINT.COM
6 ; DESCRIPTIVE NAME: DOS PRINT program for background printing of
7 ; text files to the list device.
9 ; FUNCTION: DOS PRINT program for background printing of
10 ; text files to the list device. The utility is
11 ; constructed of 3 .SAL files. They are:
13 ; PRINT_R.SAL - The resident portion of PRINT
14 ; PRINT_T.SAL - The transient portion of PRINT
15 ; PRINT_SR.SAL - The service routines of PRINT
17 ; NOTE: The Link order is VERY important for this module.
18 ; This is due to the Resident/Transient nature of
21 ; INT 28H is a software interrupt generated by the
22 ; DOS in its I/O wait loops. This spooler
23 ; can be assembled for operation using only this
24 ; interrupt which is portable from system to
25 ; system. It may also be assembled to use a
26 ; hardware timer interrupt in addition to the
27 ; software INT 28H. The purpose of using
28 ; hardware interrupts is to allow printing to
29 ; continue during programs which do not enter
30 ; the system and therefore causes the INT 28H to
31 ; go away. A timer interrupt is chosen in
32 ; preference to a "printer buffer empty" interrupt
33 ; because PRINT in the timer form is generic. It
34 ; can be given the name of any currently installed
35 ; character device as the "printer", this makes it
36 ; portable to devices which are installed by the
37 ; user even in the hardware case. It could be
38 ; Revised to use a buffer empty interrupt (no
39 ; code is given for this case), if this is done
40 ; the PROMPT and BADMES messages and their
41 ; associated code should be removed as PRINT will
42 ; then be device specific.
44 ; NOTE From Aaron Reynolds
46 ; BEWARE ALL YEE WHO ENTER HERE.
47 ; PRINT is an amazingly complex program. MS-DOS versions below 3.00 are
48 ; NOT re-entrant, this means that this utility is basically not a
49 ; possibility. It gets by on the fact that it is written by the same
50 ; person who wrote the OS. Since you are not that person, you must be very
51 ; careful about making any modification to this utility. There are a
52 ; number of things which may seem to be unnecessary on first examination.
53 ; BEWARE, almost every line of code is there for a very good reason. The
54 ; order of things is very carefully chosen. PRINT is full of potential
55 ; windows, make sure that you do not open one by careless modification. Do
56 ; not look for a lot of help from the comments, a complete explanation
57 ; would probably fill a book. A succesful modifier will have an in-depth
58 ; knowledge of the internal function of MS-DOS, and of the PRINT utility
59 ; itself through in depth study of the comments AND the code.
69 ; INTERNAL REFERENCES:
75 ; EXTERNAL REFERENCES:
83 ; REVISION HISTORY: Ax000 Version 4.0 05/01/87 - first release FG
84 ; Ax001 DCR D201 - Extended Atrib change FG
85 ; Ax002 P 1175 - move msgs back to TRANS FG
86 ; Ax003 P 1487 - PARSE error message problemFG
87 ; Ax004 P 1546 - PARSE error trailing : FG
88 ; Ax005 P 1717 - multiples of same switch FG
89 ; Ax006 P 1996 - Extended open error FG
90 ; Ax007 P 2052 - [PRN] prompt lpt1 error FG
91 ; Ax008 P 2053 - CPSW prints empty file FG
92 ; Ax009 P 2229 - filename truncation FG
93 ; Ax010 D 389 - use transname /server DOS FG
94 ; Ax011 P 3122 - attrib missing /server DOS FG
95 ; Ax012 P 3949 - Error in opening an open FG
96 ; Ax013 P 3949 - open mode - second attempt FG
97 ; Ax014 P 4396 - some messages need STDOUT FG
98 ; Ax015 P 4880 - DRIVERS not recognized FG
100 ; PRE-VERSION 4.0 HISTORY:
104 ; New INT 2FH interface, Pathnames, context switch.
105 ; V2.50 09/14/83 M.A.U
106 ; Turned it back to a print
108 ; Repaired bug in file cancel code
110 ; Added int 23 and 24 handlers to transient.
112 ; Allways checks for valid drive.
113 ; V3.00 02/03/84 M.A.U
114 ; Partitioned so as to assemble on a PC
115 ; By the by, it is V3.00 now.
117 ; Chains into INT19 (bootstrap) to unhook
118 ; INT_1C (timer) and INT_15 (AT's Wait On Event)
120 ; COPYRIGHT: "The DOS PRINT Utility"
121 ; "Version 4.00 (C) Copyright 1988 Microsoft
122 ; "Licenced Material - Program Property of Microsoft"
125 ;******************* END OF SPECIFICATIONS *************************************
126 subttl PRINT - Program Organization
128 ;******************* START PROGRAM ORGANIZATION *******************************
131 ;Group / Label Contents File
132 ; ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ Ä¿
133 ;CODER ³ Data buffer ³ Ã PRINT_RM
134 ; ÃÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ´ ÄÙ
139 ;filequeue --- ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³
141 ; ³ Initalization³ ÃÄ PRINT_R
143 ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³
144 ; ÃÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ´ ÄÙ
146 ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³
148 ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³
150 ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ÃÄ PRINT_TM
152 ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³
154 ; ÃÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ´ ÄÙ
157 ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³
159 ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³
163 ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³
164 ; ³ Transient ³ ÃÄ PRINT_T
166 ; ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´ ³
168 ;transsize --- ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÄÙ
171 ;******************* END ROGRAM ORGANIZATION ********************************
173 subttl PRINT - Data Space
186 HARDINT EQU FALSE ;No hardware ints
187 AINT EQU FALSE ;No need to do interrupt acknowledge
192 INTLOC EQU 1CH ;Hardware interrupt location (Timer)
193 REBOOT EQU 19H ;ROM BIOS "Bootstrap"
194 AINT EQU TRUE ;Acknowledge interrupts
195 EOI EQU 20H ;End Of Interrupt "instruction"
196 AKPORT EQU 20H ;Interrupt Acknowledge port
199 ; The following values have to do with the ERRCNT variable and the CNTMES
200 ; message. The values define levels at wich it is assumed an off-line error
201 ; exists. ERRCNT1 defines the value of ERRCNT above which the CNTMES message
202 ; is printed by the transient. ERRCNT2 defines the value of ERRCNT above
203 ; which the resident will give up trying to print messages on the printer, it
204 ; is much greater than ERRCNT1 because a much tighter loop is involved. The
205 ; bounding event which determines the correct value is the time required to
217 ;WARNING DANGER WARNING:
218 ; PRINT is a systems utility. It is clearly understood that it may have
219 ; to be entirely re-written for future versions of MS-DOS. The following
220 ; TWO vectors are version specific, they may not exist at all in future
221 ; versions. If they do exist, they may function differently.
222 ; ANY PROGRAM WHICH IMITATES PRINTS USE OF THESE VECTORS IS ALSO A SYSTEMS
223 ; UTILITY AND IS THEREFORE NOT VERSION PORTABLE IN ANY WAY SHAPE OR FORM.
224 ; YOU HAVE BEEN WARNED, "I DID IT THE SAME WAY PRINT DID" IS NOT AN REASON
225 ; TO EXPECT A PROGRAM TO WORK ON FUTURE VERSIONS OF MS-DOS.
227 SOFTINT EQU 28H ;Software interrupt generated by DOS
228 ComInt EQU 2FH ;Communications interrupt used by PSPRINT
229 ; Multiplex number 0 and 1
231 ;----- Default (and Maximal / Minimal) Print queue length
232 MinQueueLen equ 4 ; 4 files worth min
233 MaxQueueLen equ 32 ; 32 files worth max.
234 DefQueueLen equ 10 ; 10 files worth
236 ;----- Default (and Maximal / Minimal) Print buffer length
237 MinBufferLen equ 512 ; set minimum to 512 bytes
238 MaxBufferLen equ 1024 * 16 ; maximum is 16 K bytes
239 DefBufferLen equ MinBufferLen ; set default to minimum
241 ;----- Default (and Maximal / Minimal) Time Slice
242 MinTimeSlice equ 1 ; set minimum to 1
243 MaxTimeSlice equ 255 ; maximum is 255
244 DefTimeSlice equ 10 ; set default to 10
246 ;----- Default (and Maximal / Minimal) Busy Tick
247 MinBusyTick equ 1 ; set minimum to 1
248 MaxBusyTick equ 255 ; maximum is 255
249 DefBusyTick equ MinBusyTick ; set default to minimum
251 ;----- Default (and Maximal / Minimal) Max Tick
252 MinMaxTick equ 1 ; set minimum to 1
253 MaxMaxTick equ 255 ; maximum is 255
254 DefMaxTick equ 2 ; set default to 2
256 ;----- Maximum length of a file name (incl nul)
259 ; **************** Bogosity Warning *****************
260 ; Below is the equate that MaxFile SHOULD be. Since the 3.0/3.1 documentation
261 ; documents each queue entry as being 64 chars long. Yes it is known that
262 ; that causes Print to misbehave on files deep in trees. But for
263 ; compatibilities sake, IBM insisted that we change the code back to the
265 ;MaxFileLen equ 63 + 2 + 12 ; 63 characters as Command.com's
267 ; 2 character for the Drive ext.
268 ; 12 characters for the max. valid
271 ;----------------------------------------
272 ; definition of the MODE bits
273 ; for an extended open
274 ;----------------------------------------
276 ; BITS DEFINED FOR THE MODE WORD
277 ; FORMAT = 0WF00000ISSS0AAA
278 ; Write ÄÄÄÄÄÄÄÄÄÄÄÙ³ ³³ ÀÄÄÄ Access code
279 ; 0 = no commit ³ ³³ 0 = read
280 ; 1 = auto commit ³ ³³ 1 = write
281 ; ³ ³³ 2 = read/write
282 ; Fail action ÄÄÄÄÄÄÄÄÄÄÄÄÙ ³³ 3 = execute
283 ; 0 = INT 24h ³³ 4 = FCB
284 ; 1 = return error ³³
286 ; ³ 0 = compatability
287 ; ³ 1 = deny read/write
292 ; 0 = pass handle to child
295 MODE_COM equ 0100000000000000b ; Auto Commit
296 MODE_NO24 equ 0010000000000000b ; No 24 - return error
297 MODE_NOINH equ 0000000010000000b ; No child procees access
299 MODE_SH_COMP equ 0000000000000000b ; 0 = compatability
300 MODE_SH_D_RW equ 0000000000010000b ; 1 = deny read/write
301 MODE_SH_D_W equ 0000000000100000b ; 2 = deny write
302 MODE_SH_D_R equ 0000000000110000b ; 3 = deny read
303 MODE_SH_D_NONE equ 0000000001000000b ; 4 = deny none
305 MODE_AC_R equ 0000000000000000b ; 0 = read
306 MODE_AC_W equ 0000000000000001b ; 1 = write
307 MODE_AC_RW equ 0000000000000010b ; 2 = read/write
308 MODE_AC_EXE equ 0000000000000011b ; 3 = execute
309 MODE_AC_FCB equ 0000000000000100b ; 4 = FCB
311 GET_CPSW equ 3 ; Get state of CPSW
312 CPSW_on equ 1 ; CPSW is active
313 major_code equ 0ADh ; INT 2F PRINT semaphore
314 minor_code equ 040h ; INT 2F PRINTER set and lock CP
316 ; The Extended Open mode is set as:
317 ; Shareing Mode - Compatability
321 ; These MUST be set this way
322 ; in order to do a second open
323 ; of a file accross the network
325 open_mode equ MODE_NO24+MODE_SH_COMP+MODE_AC_R ;AC013;
328 ignore_cp equ 1 ; dont validate CP - it may be different
331 openit equ 1 ; extended open 'exsists' action
332 failopen equ 0 ; extended open 'does not exsist' action
334 Cap_ASCIIZ equ 22h ; Capitalize ASCIIZ string (INT 21 - 65)
336 ;----- Message related information
338 ;================================================
339 ; PRINT Message Skeleton File
340 ;================================================
361 ;1 - Too many operands
362 ;2 - Required operand missing
363 ;use PARSE3 ;3 - Not in switch list provided
364 ;4 - Not in keyword list provided
365 ;use PARSE6 ;6 - Out of range specified
366 ;7 - Not in value list provided
367 ;8 - Not in string list provided
368 ;use PARSE9 ;9 - Invalid Parameter
372 ;def 6 " error reading file",CR,LF,"$"
373 ;def 7 "File not found",CR,LF,"$"
374 ;def 8 CR,LF,LF,"File $"
375 ;def 9 " canceled by operator$"
376 ;def 10 CR,LF,LF,"All files canceled by operator$"
377 ;def 11 "File allocation table bad drive "
378 ;def 12 "A.",CR,LF,"$"
379 ;def 13 "List output is not assigned to a device",CR,LF
380 ;def 14 "Resident part of PRINT installed",CR,LF
386 ;def 15 "Cannot use PRINT - Use NET PRINT",CR,LF
387 ;def 17 "PRINT queue is full",CR,LF
388 ;def 18 "PRINT queue is empty",CR,LF
389 ;def 19 "Access denied",CR,LF
390 ;def 20 "Invalid drive specification",CR,LF
391 ;def 21 "Errors on list device indicate that it",CR,LF
392 ; "may be off-line. Please check it.",CR,LF
396 ;def 22 CR,LF,LF," %1 is currently being printed",CR,LF
397 ;def 23 " %1 is in queue",CR,LF
399 ;def 25 "Pathname too long",CR,LF
400 ;def 26 "File not in PRINT queue",CR,LF
404 ;def 27 "Name of list device [PRN]: "
407 ;--------------------------------------
409 ;--------------------------------------
411 MesSerCLASS equ 0 ; Message Service class
412 DOS_error equ 1 ; DOS extended error
413 Parse_error equ 2 ; Parse error
414 CLASS_A equ 0Ah ; PRINT_R message
415 CLASS_B equ 0Bh ; PRINT_T message
416 CLASS_C equ 0Ch ; PRINT_T message with insert
417 CLASS_D equ 0Dh ; PRINT_T message with input buffer where:
418 CLASS_Util equ 0FFh ; PRINT utility message (Class A - D)
419 buffered_input equ 0Ah ; Buffered keyboard input
428 INVPARM equ 9 ; Invalid parameter (PARSE)
432 ERRMEST equ 6 ; error reading file
433 ErrMesT2 equ 7 ; File not found
435 CanFilNam equ 9 ; canceled by operator
436 AllCan equ 10 ; All files canceled by operator
437 FATMES equ 11 ; File allocation table bad drive
439 BADMES equ 13 ; List output is not assigned to a device
440 GOODMES equ 14 ; Resident part of PRINT installed
444 NEXT_LINE equ 2 ; advance to next line
445 CONFLICTMES equ 15 ; Cannot use PRINT - Use NET PRINT
446 FULLMES equ 17 ; PRINT queue is full
447 NoFils equ 18 ; PRINT queue is empty
448 AccDen equ 19 ; Access denied
449 InvDrvMes equ 20 ; Invalid drive specification
450 CNTMES equ 21 ; Errors on list device indicate that it
451 ; may be off-line. Please check it.
455 FstMes equ 22 ; %1 is currently being printed
456 SecMes equ 23 ; %1 is in queue
457 BadNameMes equ 24 ; %1 File not found
458 NamTMes equ 25 ; %1 Pathname too long
459 BadCanMes equ 26 ; %1 File not in PRINT queue
463 PROMPT equ 27 ; Name of list device [PRN]:
468 ; $SALUT (0,41,46,52)
477 SaveReg MACRO reglist ;; push those registers
484 RestoreReg MACRO reglist ;; pop those registers
489 ; $SALUT (4,25,30,41)
509 error_queue_full EQU 8
510 error_name_too_long EQU 12
511 get_ea_by_handle equ 2
521 BREAK <Segment Definitions>
524 CodeR Segment public para
527 Code Segment public para
530 Data Segment public byte
536 DG group Code,Data,Stack