da Silva, Joe wrote:
> 
>   DOS reserves five special file handles for use by itself and
> applications programs. They are:
> 
> |-----------------------------------------------------------------------|
> | 0000h | STDIN  | standard input device   (input can be redirected)    |
> | 0001h | STDOUT | standard output device  (output can be redirected)   |
> | 0002h | STDERR | standard error output device (output cannot be       |
> |       |        |                               redirected)            |
> |       |        | NOTE: DOS opens STDERR for both writing and reading. |
> |       |        |  Since STDIN can be redirected, using STDERR to read |
> |       |        |  the keyboard is a reliable way to ensure that your  |
> |       |        |  program is actually                                 |
> |       |        | reading the keyboard, if that's what you want to do. |
> | 0004h | STDAUX | standard auxiliary device                            |
> | 0005h | STDPRN | standard printer device (PRN, normally LPT1)         |
> |-----------------------------------------------------------------------|
> 
>   These handles are predefined by DOS and can be used by an
> application program.  They do not need to be opened by a program,
> although a program can close these handles.  STDIN should be treated
> as a read-only file, and STDOUT and STDERR should be treated as write-
> only files.  STDIN and STDOUT can be redirected.  All handles
> inherited by a process can be redirected, but not at the command line.
> 
> [BTW, I was puzzled by that last line at first, but all
>  I think it is saying, is just that only STDIN and STDOUT
>  can be redirected via the command line ... Joe]

I think it is saying they are re-directed by inheritance, and you can't
change it. 

BTW, I thought it might be of interest to see the difference in overhead
required for handle console text output via a file handle:

Here is the "standard" character method:

mov     dx,offset signon
mov     ah,09h
int     21

Here is the file handle method as used by a respected co. we DON'T complain
about and dissassembled by me:

L0131H:  MOV   AX,OFFSET SIGNON  ;Sign on
         CALL  L0209H            ;Writes file or device

L0209H:  MOV   SI,AX
         CALL  L0234H
         MOV   BX,DS:[OFFSET WHANDLE]
         MOV   DX,SI
         XCHG  CX,AX
         MOV   AH,64H            ;Write to file/device.
         INT   21H
         JMP   L0252H

L0234H:  CALL  L0242H            ;*WHY? Does everything get trashed ?
         PUSH  SI
         XCHG  SI,AX
         MOV   DX,0FFFFH
L0239H:  LODSB                   ;Load AL with byte at (SI)+-.
         INC   DX                ;Count the bytes
         TEST  AL,AL
         JNZ   L0239H
         XCHG  DX,AX
         POP   SI
         RET

L0242H:  POP   DS:[OFFSET SAVERTN]             ;SAVE RETURN ADDRESS
         PUSH  ES
         PUSH  BP
         PUSH  SI
         PUSH  DI
         PUSH  BX
         PUSH  CX
         PUSH  DS
         POP   ES
         JMP   DS:[OFFSET WORD PTR SAVERTN]    ;YUP

L0252H:  POP   CX
         POP   BX
         POP   DI
         POP   SI
         POP   BP
         POP   ES
         RET

Cheers.

-  Clarence Verge
--
-  Help stamp out FATWARE.  As a start visit: http://home.arachne.cz/
--


Reply via email to