     1                                  ;	SCCSID = @(#)cpmio.asm	1.1 85/04/10
     2                                  ;TITLE	CPMIO - device IO for MSDOS
     3                                  ;NAME	CPMIO
     4                                  ;
     5                                  ; Standard device IO for MSDOS (first 12 function calls)
     6                                  ;
     7                                  
     8                                  [list -]
     8          ******************       warning: redefining multi-line macro `struc' [-w+pp-macro-redef-multi]
    14                              <4> [list -]
    14                              <3> [list -]
     3                              <2> 
     4                              <2> addsection DOSSTART, align=16 PUBLIC class=DOSSTART
     5                              <2> ; (no prior section) ; DOSSTART		ENDS
     6                              <2> 
     7                              <2> addsection DOSSTARTJUMP, align=1 PUBLIC class=START
     8                              <2> ; (no prior section) ; DOSSTARTJUMP		ENDS
     9                              <2> 
    10                              <2> addsection CONSTANTS, align=2 PUBLIC class=CONST
    11                              <2> ; (no prior section) ; CONSTANTS	ENDS
    12                              <2> 
    13                              <2> addsection DATA, align=2 PUBLIC class=DATA
    14                              <2> ; (no prior section) ; DATA		ENDS
    15                              <2> 
    16                              <2> addsection TABLE, align=2 PUBLIC class=TABLE
    17                              <2> ; (no prior section) ; TABLE		ENDS
    18                              <2> 
    19                              <2> addsection DOSDATATABLE, align=2 PUBLIC class=DOSDATACODE
    20                              <2> ; (no prior section) ; DOSDATATABLE		ENDS
    21                              <2> 
    22                              <2> addsection DOSDATACODE, align=1 PUBLIC class=DOSDATACODE
    23                              <2> ; (no prior section) ; DOSDATACODE		ENDS
    24                              <2> 
    25                              <2> addsection DOSBIODATA, align=2 PUBLIC class=DOSBIODATA
    26                              <2> 
    27                              <2> addsection LAST, align=16 PUBLIC class=LAST
    28                              <2> ; (no prior section) ; LAST		ENDS
    29                              <2> 
    30                              <2> group DOSGROUP DOSSTART DOSSTARTJUMP CONSTANTS DATA TABLE DOSDATATABLE DOSDATACODE DOSBIODATA LAST
     8                              <1> 
     9                              <1> %include "dcodeseg.nas"
     1                              <2> 
     2                              <2> %ifndef DCODESEGNAS
     3                              <2> %assign DCODESEGNAS 1
     4                              <2> 
     5                              <2> section DOSCODETABLE align=2 PUBLIC class=DOSCODE
     6                              <2> ; (no prior section) ; DOSCODETABLE		ENDS
     7                              <2> section DOSCODECODE align=1 PUBLIC class=DOSCODE
     8                              <2> ; (no prior section) ; DOSCODECODE		ENDS
     9                              <2> section DOSBIOCODE align=2 PUBLIC class=DOSCODE
    10                              <2> section BIOCODE	align=2 PUBLIC class=DOSCODE
    11                              <2> 
    12                              <2> %ifnidni DOSENTRYGROUP, DOSCODEGROUP
    13                              <2>  group DOSCODEGROUP DOSCODETABLE DOSCODECODE DOSBIOCODE BIOCODE
    14                              <2> %endif
    15                              <2> 
    16                              <2> %endif
    10                              <1> 
    11                              <1> section LAST
    12                              <1> ; (no prior section) ; LAST		ENDS
    11                                  ;.cref
    12                                  [list +]
    13                                  
    14                                  ;
    15                                  ; Old style CP/M 1-12 system calls to talk to reserved devices
    16                                  ;
    17                                  ;   $Std_Con_Input_No_Echo
    18                                  ;   $Std_Con_String_Output
    19                                  ;   $Std_Con_String_Input
    20                                  ;   $RawConIO
    21                                  ;   $RawConInput
    22                                  ;   RAWOUT
    23                                  ;   RAWOUT2
    24                                  ;
    25                                  ;   Revision history:
    26                                  ;
    27                                  ;     A000     version 4.00 - Jan 1988
    28                                  ;     A002     PTM    -- dir >lpt3 hangs
    29                                  ;
    30                                  ;
    31                                  ;
    32                                  ;
    33                                  ;
    34                                  ;
    35                                  ;
    36                                  ;
    37                                  ;
    38                                  ;
    39                                  
    40                                  section DOSCODECODE
    41                                  
    42                                  ;.xcref
    43                                  [list -]
    43          ******************       warning: out: ... for DOS Version 4.00 ... [-w+user]
    43          ******************       warning: out: BPB.INC... [-w+user]
    43          ******************       warning: out: ... CLONE version build switch on ... [-w+user]
    43          ******************       warning: out: DEVSYM.INC... [-w+user]
    48                                  ;.cref
    49                                  
    50                                  %ifndef KANJI
    51                                   %iassign KANJI 0	;FALSE
    52                                  %endif
    53                                  
    54                                  ; The following routines form the console I/O group (funcs 1,2,6,7,8,9,10,11).
    55                                  ; They assume ES and DS NOTHING, while not strictly correct, this forces data
    56                                  ; references to be SS or CS relative which is desired.
    57                                  
    58                                      i_need  CARPOS,BYTE
    59                                      i_need  STARTPOS,BYTE
    60                                      i_need  INBUF,128
    61                                      i_need  INSMODE,BYTE
    62                                      i_need  user_SP,WORD
    63                                      EXTRN   EscChar:BYTE		; lead byte for function keys
    64                                      EXTRN   CanChar:BYTE		; Cancel character
    65                                      EXTRN   OUTCHA:NEAR 		;AN000 char out with status check 2/11/KK
    66                                      i_need  Printer_Flag,BYTE
    67                                      i_need  SCAN_FLAG,BYTE
    68                                      i_need  DATE_FLAG,WORD
    69                                      i_need  Packet_Temp,WORD		; temporary packet used by readtime
    70                                      i_need  DEVCALL,DWORD
    71                                      i_need  InterChar,BYTE		;AN000;interim char flag ( 0 = regular char)
    72                                      i_need  InterCon,BYTE		;AN000;console flag ( 1 = in interim mode )
    73                                      i_need  SaveCurFlg,BYTE		;AN000;console out ( 1 = print and do not advance)
    74                                      i_need  COUNTRY_CDPG,byte		;AN000; 	2/12/KK
    75                                      i_need  TEMP_VAR,WORD		;AN000; 	2/12/KK
    76                                      i_need  DOS34_FLAG,WORD		;AN000; 	2/12/KK
    77                                  	i_need FETCHI_TAG, word
    78                                  
    79                                  
    80                                   assume nocheck, ss:DOSGROUP
    81                                  
    82                                  Break
    83                                   %IF  DBCS							  ;AN000;
    84                                  
    85                                  ;-------------------------------- Start of Korean Support 2/11/KK
    86                                  	procedure   D_STD_CON_INPUT_NO_ECHO,NEAR   ;System call 8  ;AN000;
    87                                  ASSUME	DS:NOTHING,ES:NOTHING					  ;AN000;
    88                                  
    89                                  StdCILop:							  ;AN000;
    90                                  	invoke	INTER_CON_INPUT_NO_ECHO 			  ;AN000;
    91                                  	transfer InterApRet		; go to return fuction	  ;AN000;
    92                                  
    93                                  EndProc D_STD_CON_INPUT_NO_ECHO					  ;AN000;
    94                                  
    95                                  	procedure   INTER_CON_INPUT_NO_ECHO,NEAR		  ;AN000;
    96                                  ASSUME	DS:NOTHING,ES:NOTHING					  ;AN000;
    97                                  ;-----------------------------------End of Korean Support 2/11/KK
    98                                  
    99                                  ; Inputs:
   100                                  ;	None
   101                                  ; Function:
   102                                  ;	Same as $STD_CON_INPUT_NO_ECHO but uses interim character read from
   103                                  ;	the device.
   104                                  ; Returns:
   105                                  ;	AL = character
   106                                  ;	Zero flag SET if interim character, RESET otherwise
   107                                  
   108                                   %ELSE								  ;AN000;
   109                                  
   110                                  
   111                                  ;
   112                                  ; Inputs:
   113                                  ;	None
   114                                  ; Function:
   115                                  ;	Input character from console, no echo
   116                                  ; Returns:
   117                                  ;	AL = character
   118                                  
   119                                  	procedure   D_STD_CON_INPUT_NO_ECHO,NEAR   ;System call 8
   119          ******************       warning: proc D_STD_CON_INPUT_NO_ECHO... [-w+user]
   120                                  ASSUME	DS:NOTHING,ES:NOTHING
   121                                  
   122                                   %ENDIF
   123 00000000 1E                      	PUSH	DS
   124 00000001 56                      	PUSH	SI
   125                                  INTEST:
   126 00000002 E8(0000)                	invoke	STATCHK
   127 00000005 7547                    	JNZ	Get
   128                                  ;*************************************************************************
   129 00000007 36803E[0000]00          	cmp	byte [ss:Printer_Flag],0	; is printer idle?
   130 0000000D 7505                    	jnz	no_sys_wait
   131 0000000F B405                    	mov	ah,5			; get input status with system wait
   132 00000011 E8(0000)                	invoke	IOFUNC
   133                                  no_sys_wait:
   134                                  ;**************************************************************************
   135 00000014 B484                    	MOV	AH,84h
   136 00000016 CD2A                    	INT	int_IBM
   137                                  
   138                                  ;;; 7/15/86  update the date in the idle loop
   139                                  ;;; Dec 19, 1986 D.C.L. changed following CMP to Byte Ptr from Word Ptr
   140                                  ;;;;		 to shorten loop in consideration of the PC Convertible
   141                                  
   142 00000018 36803E[0000]FF          	CMP	byte ptr [ss:DATE_FLAG],-1 ; date is updated may be every
   143 0000001E 7527                    	JNZ	NoUpdate		; 65535 x ? ms if no one calls
   144 00000020 50                      	PUSH	AX
   145 00000021 53                      	PUSH	BX			; following is tricky,
   146 00000022 51                      	PUSH	CX			; it may be called by critical handler
   147 00000023 52                      	PUSH	DX			; at that time, DEVCALL is used by
   148                                  					; other's READ or WRITE
   149 00000024 1E                      	PUSH	DS			; save DS = SFT's sgement
   150 00000025 16                      	PUSH	ss			; READTIME must use DS=CS
   151 00000026 1F                      	POP	DS
   152                                   assume ds:DOSGROUP
   153                                  
   154 00000027 B80000                  	MOV	AX,0			; therefore, we save DEVCALL
   155 0000002A E8DC02                  	CALL	Save_Restore_Packet	; save DEVCALL packet
   156 0000002D E8(0000)                	invoke	READTIME		; readtime
   157 00000030 B80100                  	MOV	AX,1
   158 00000033 E8D302                  	CALL	Save_Restore_Packet	; restore DEVCALL packet
   159                                  
   160 00000036 36813E[0000]7258        	CMP	word ptr [ss:FETCHI_TAG],22642
   161 0000003D 7403                    	JZ	check_ok
   162 0000003F E8(0000)                	invoke	TAGCRASHDOS		; should never come here
   163                                  check_ok:
   164                                  
   165 00000042 1F                      	POP	DS			; restore DS
   166                                   assume ds:nothing
   167 00000043 5A                      	POP	DX
   168 00000044 59                      	POP	CX
   169 00000045 5B                      	POP	BX
   170 00000046 58                      	POP	AX
   171                                  NoUpdate:
   172 00000047 36FF06[0000]            	INC	word [ss:DATE_FLAG]
   173                                  
   174                                  ;;; 7/15/86 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   175                                  Intest equ INTEST	; NASM port label
   176 0000004C EBB4                    	JMP	Intest
   177                                  Get:
   178 0000004E 30E4                    	XOR	AH,AH
   179 00000050 E8(0000)                	invoke	IOFUNC
   180 00000053 5E                      	POP	SI
   181 00000054 1F                      	POP	DS
   182                                   assume ds:nothing
   183                                  ;;; 7/15/86
   184 00000055 36C606[0000]00          	MOV	BYTE PTR [ss:SCAN_FLAG],0
   185 0000005B 3C00                    	CMP	AL,0	    ; extended code ( AL )
   186 0000005D 7506                    	JNZ	noscan
   187 0000005F 36C606[0000]01          	MOV	BYTE PTR [ss:SCAN_FLAG],1	; set this flag for ALT_Q key
   188                                  
   189                                  noscan:
   190                                  ;;; 7/15/86
   191                                   %IF  DBCS			    ;AN000;
   192                                  	cmp	byte [ss:InterChar],1    ;AN000; set the zero flag if the character3/31/KK ;AN000;
   193                                   %ENDIF				    ;AN000;
   194 00000065 C3                      	return
   195                                   %IF  DBCS			    ;AN000;
   196                                  EndProc INTER_CON_INPUT_NO_ECHO     ;AN000;  ;2/11/KK				      ;AN000;
   197                                   %ELSE				    ;AN000;
   198                                  EndProc D_STD_CON_INPUT_NO_ECHO
   199                                   %ENDIF				    ;AN000;
   200                                  
   201                                  Break
   202                                  
   203                                  ; Inputs:
   204                                  ;	DS:DX Point to output string '$' terminated
   205                                  ; Function:
   206                                  ;	Print the string on the console device
   207                                  ; Returns:
   208                                  ;	None
   209                                  
   210                                  	procedure   D_STD_CON_STRING_OUTPUT,NEAR   ;System call 9
   210          ******************       warning: proc D_STD_CON_STRING_OUTPUT... [-w+user]
   211                                  ASSUME	DS:NOTHING,ES:NOTHING
   212                                  
   213 00000066 89D6                    	MOV	SI,DX
   214                                  STRING_OUT1:
   215 00000068 AC                      	LODSB
   216                                   %IF  DBCS				;AN000;
   217                                  	invoke	TESTKANJ		;AN000; 	      2/11/KK		 ;AN000;
   218                                  	jz	SBCS00			;AN000; 	      2/11/KK		 ;AN000;
   219                                  	invoke	OUTT			;AN000; 	      2/11/KK		 ;AN000;
   220                                  	LODSB				;AN000; 	      2/11/KK		 ;AN000;
   221                                  	JMP	NEXT_STR1		;AN000; 	      2/11/KK		 ;AN000;
   222                                  SBCS00: 				;AN000; 	      2/11/KK		 ;AN000;
   223                                   %ENDIF					;AN000;
   224 00000069 3C24                    	CMP	AL,'$'
   225 0000006B 74F8                    	retz
   226                                  NEXT_STR1:
   227 0000006D E8(0000)                	invoke	OUTT
   228 00000070 EBF6                    	JMP	STRING_OUT1
   229                                  
   230                                  EndProc D_STD_CON_STRING_OUTPUT
   231                                  
   232                                  %IF  DBCS				;AN000;
   233                                  ;=== Push trace listing source: kstrin.nas
   234                                  %include "kstrin.nas"			;AN000;
   235                                  ;=== Pop trace listing source
   236                                  %ELSE					;AN000;
   237                                  ;=== Push trace listing source: strin.nas
   238                                  %include "strin.nas"
     1                              <1> ;       SCCSID = @(#)strin.asm  1.2 85/04/18
     2                              <1> Break
     3                              <1> 
     4                              <1>  assume nocheck, ss:DOSGROUP
     5                              <1> 
     6                              <1> ; Inputs:
     7                              <1> ;       DS:DX Point to an input buffer
     8                              <1> ; Function:
     9                              <1> ;       Fill buffer from console input until CR
    10                              <1> ; Returns:
    11                              <1> ;       None
    12                              <1> 
    13                              <1>         procedure   D_STD_CON_STRING_INPUT,NEAR   ;System call 10
    13          ******************  <1>  warning: proc D_STD_CON_STRING_INPUT... [-w+user]
    14                              <1> ASSUME  DS:NOTHING,ES:NOTHING
    15                              <1> 
    16 00000072 8CD0                <1>         MOV     AX,SS
    17 00000074 8EC0                <1>         MOV     ES,AX
    18                              <1>  assume es:DOSGROUP
    19 00000076 89D6                <1>         MOV     SI,DX
    20 00000078 30ED                <1>         XOR     CH,CH
    21 0000007A AD                  <1>         LODSW
    22                              <1> ;
    23                              <1> ; AL is the buffer length
    24                              <1> ; AH is the template length
    25                              <1> ;
    26 0000007B 08C0                <1>         OR      AL,AL
    27 0000007D 74E6                <1>         retz                    ;Buffer is 0 length!!?
    28 0000007F 88E3                <1>         MOV     BL,AH           ;Init template counter
    29 00000081 88EF                <1>         MOV     BH,CH           ;Init template counter
    30                              <1>  ;
    31                              <1>  ; BL is the number of bytes in the template
    32                              <1>  ;
    33 00000083 38D8                <1>         CMP     AL,BL
    34 00000085 7605                <1>         JBE     NOEDIT          ;If length of buffer inconsistent with contents
    35 00000087 80380D              <1>         CMP     BYTE PTR [BX+SI],c_CR
    36 0000008A 7402                <1>         JZ      EDITON          ;If CR correctly placed EDIT is OK
    37                              <1> ;
    38                              <1> ; The number of chars in the template is >= the number of chars in buffer or
    39                              <1> ; there is no CR at the end of the template.  This is an inconsistant state
    40                              <1> ; of affairs.  Pretend that the template was empty:
    41                              <1> ;
    42                              <1> NOEDIT:
    43 0000008C 88EB                <1>         MOV     BL,CH           ;Reset buffer
    44                              <1> EDITON:
    45 0000008E 88C2                <1>         MOV     DL,AL
    46 00000090 4A                  <1>         DEC     DX              ;DL is # of bytes we can put in the buffer
    47                              <1> ;
    48                              <1> ; Top level.  We begin to read a line in.
    49                              <1> ;
    50                              <1> NEWLIN:
    51 00000091 36A0[0000]          <1>         MOV     AL,[ss:CARPOS]
    52 00000095 36A2[0000]          <1>         MOV     [ss:STARTPOS],AL   ;Remember position in raw buffer
    53 00000099 56                  <1>         PUSH    SI
    54 0000009A BF[0000]            <1>         MOV     DI,OFFSET INBUF wrt DOSGROUP        ;Build the new line here
    55 0000009D 36882E[0000]        <1>         MOV     [ss:INSMODE],CH    ;Insert mode off
    56 000000A2 88EF                <1>         MOV     BH,CH           ;No chars from template yet
    57 000000A4 88EE                <1>         MOV     DH,CH           ;No chars to new line yet
    58 000000A6 E857FF              <1>         invoke  D_STD_CON_INPUT_NO_ECHO          ;Get first char
    59 000000A9 3C0A                <1>         CMP     AL,c_LF         ;Linefeed
    60 000000AB 7503                <1>         JNZ     GOTCH           ;Filter out LF so < works
    61                              <1> ;
    62                              <1> ; This is the main loop of reading in a character and processing it.
    63                              <1> ;
    64                              <1> ;   BH is the index of the next byte in the template
    65                              <1> ;   BL is the length of the template
    66                              <1> ;   DH is the number of bytes in the buffer
    67                              <1> ;   DL is the length of the buffer
    68                              <1> ;
    69                              <1> entry   GETCH
    70 000000AD E850FF              <1>         invoke  D_STD_CON_INPUT_NO_ECHO
    71                              <1> GOTCH:
    72                              <1> ;
    73                              <1> ; Brain-damaged TP ignored ^F in case his BIOS did not flush the
    74                              <1> ; input queue.
    75                              <1> ;
    76 000000B0 3C06                <1>         CMP     AL,"F"-"@"
    77 000000B2 74F9                <1>         JZ      GETCH
    78                              <1> ;
    79                              <1> ; If the leading char is the function-key lead byte
    80                              <1> ;
    81                              <1> ESCCHAR equ EscChar	; NASM port label
    82 000000B4 363A06[0000]        <1>         CMP     AL,[ss:ESCCHAR]
    83 000000B9 7443                <1>         JZ      ESCape          ;change reserved keyword DBM 5-7-87
    84                              <1> ;
    85                              <1> ; Rubout and ^H are both destructive backspaces.
    86                              <1> ;
    87 000000BB 3C7F                <1>         CMP     AL,c_DEL
    88 000000BD 7436                <1>         JZ      BACKSPJ
    89 000000BF 3C08                <1>         CMP     AL,c_BS
    90 000000C1 7432                <1>         JZ      BACKSPJ
    91                              <1> ;
    92                              <1> ; ^W deletes backward once and then backs up until a letter is before the
    93                              <1> ; cursor
    94                              <1> ;
    95 000000C3 3C17                <1>         CMP     AL,"W" - "@"
    96                              <1> ; The removal of the comment characters before the jump statement will
    97                              <1> ; cause ^W to backup a word.
    98                              <1> ;***    JZ      WordDel
    99 000000C5 90                  <1>         NOP
   100 000000C6 90                  <1>         NOP
   101 000000C7 3C15                <1>         CMP     AL,"U" - "@"
   102                              <1> ; The removal of the comment characters before the jump statement will
   103                              <1> ; cause ^U to clear a line.
   104                              <1> ;***    JZ      LineDel
   105 000000C9 90                  <1>         NOP
   106 000000CA 90                  <1>         NOP
   107                              <1> 
   108                              <1> ;
   109                              <1> ; CR terminates the line.
   110                              <1> ;
   111 000000CB 3C0D                <1>         CMP     AL,c_CR
   112 000000CD 7432                <1>         JZ      ENDLIN
   113                              <1> ;
   114                              <1> ; LF goes to a new line and keeps on reading.
   115                              <1> ;
   116 000000CF 3C0A                <1>         CMP     AL,c_LF
   117 000000D1 7444                <1>         JZ      PHYCRLF
   118                              <1> ;
   119                              <1> ; ^X (or ESC) deletes the line and starts over
   120                              <1> ;
   121                              <1> CANCHAR equ CanChar	; NASM port label
   122 000000D3 363A06[0000]        <1>         CMP     AL,[ss:CANCHAR]
   123 000000D8 746B                <1>         JZ      KILNEW
   124                              <1> ;
   125                              <1> ; Otherwise, we save the input character.
   126                              <1> ;
   127                              <1> SAVCH:
   128 000000DA 38D6                <1>         CMP     DH,DL
   129 000000DC 7319                <1>         JAE     BUFFUL                  ; buffer is full.
   130 000000DE AA                  <1>         STOSB
   131 000000DF FEC6                <1>         INC     DH                      ; increment count in buffer.
   132 000000E1 E8(0000)            <1>         invoke  BUFOUT                  ;Print control chars nicely
   133 000000E4 36803E[0000]00      <1>         CMP     BYTE PTR [ss:INSMODE],0
   134 000000EA 75C1                <1>         JNZ     GETCH                   ; insertmode => don't advance template
   135 000000EC 38DF                <1>         CMP     BH,BL
   136 000000EE 73BD                <1>         JAE     GETCH                   ; no more characters in template
   137 000000F0 46                  <1>         INC     SI                      ; Skip to next char in template
   138 000000F1 FEC7                <1>         INC     BH                      ; remember position in template
   139 000000F3 EBB8                <1>         JMP     SHORT GETCH
   140                              <1> 
   141                              <1> BACKSP equ BackSp	; NASM port label
   142 000000F5 EB61                <1> BACKSPJ: JMP    SHORT BACKSP
   143                              <1> 
   144                              <1> BUFFUL:
   145 000000F7 B007                <1>         MOV     AL,7                    ; Bell to signal full buffer
   146 000000F9 E8(0000)            <1>         invoke  OUTT
   147 000000FC EBAF                <1>         JMP     SHORT GETCH
   148                              <1> 
   149                              <1> ESCape:                         ;change reserved keyword DBM 5-7-87
   150 000000FE E9(0000)            <1>         transfer    OEMFunctionKey      ; let the OEM's handle the key dispatch
   151                              <1> 
   152                              <1> ENDLIN:
   153 00000101 AA                  <1>         STOSB                           ; Put the CR in the buffer
   154 00000102 E8(0000)            <1>         invoke  OUTT                    ; Echo it
   155 00000105 5F                  <1>         POP     DI                      ; Get start of user buffer
   156 00000106 8875FF              <1>         MOV     [DI-1],DH               ; Tell user how many bytes
   157 00000109 FEC6                <1>         INC     DH                      ; DH is length including CR
   158                              <1> entry COPYNEW
   159 0000010B 1E06                <1>         SaveReg <DS,ES>
   160 0000010D 1F07                <1>         RestoreReg <DS,ES>              ; XCHG ES,DS
   161 0000010F BE[0000]            <1>         MOV     SI,OFFSET INBUF wrt DOSGROUP
   162 00000112 88F1                <1>         MOV     CL,DH                   ; set up count
   163 00000114 F3A4                <1>         REP     MOVSB                   ; Copy final line to user buffer
   164 00000116 C3                  <1>         return
   165                              <1> ;
   166                              <1> ; Output a CRLF to the user screen and do NOT store it into the buffer
   167                              <1> ;
   168                              <1> PHYCRLF:
   169 00000117 E84B01              <1>         invoke  CRLF
   170 0000011A EB91                <1>         JMP     GETCH
   171                              <1> 
   172                              <1> ;
   173                              <1> ; Delete the previous line
   174                              <1> ;
   175                              <1> LineDel:
   176 0000011C 08F6                <1>         OR      DH,DH
   177                              <1> GetCh equ GETCH	; NASM port label
   178 0000011E 748D                <1>         JZ      GetCh
   179 00000120 E83B00              <1>         Call    BackSpace
   180 00000123 EBF7                <1>         JMP     LineDel
   181                              <1> 
   182                              <1> ;
   183                              <1> ; delete the previous word.
   184                              <1> ;
   185                              <1> WordDel:
   186                              <1> WordLoop:
   187 00000125 E83600              <1>         Call    BackSpace               ; backspace the one spot
   188 00000128 08F6                <1>         OR      DH,DH
   189 0000012A 7416                <1>         JZ      GetChJ
   190 0000012C 268A45FF            <1>         MOV     AL,[ES:DI-1]
   191 00000130 3C30                <1>         cmp     al,'0'
   192                              <1> GetChj equ GetChJ	; NASM port label
   193 00000132 720E                <1>         jb      GetChj
   194 00000134 3C39                <1>         cmp     al,'9'
   195 00000136 76ED                <1>         jbe     WordLoop
   196 00000138 0C20                <1>         OR      AL,20h
   197 0000013A 3C61                <1>         CMP     AL,'a'
   198 0000013C 7204                <1>         JB      GetChJ
   199 0000013E 3C7A                <1>         CMP     AL,'z'
   200 00000140 76E3                <1>         JBE     WordLoop
   201                              <1> GetChJ:
   202 00000142 E968FF              <1>         JMP     GetCh
   203                              <1> ;
   204                              <1> ; The user wants to throw away what he's typed in and wants to start over.  We
   205                              <1> ; print the backslash and then go to the next line and tab to the correct spot
   206                              <1> ; to begin the buffered input.
   207                              <1> ;
   208                              <1>         entry   KILNEW
   209 00000145 B05C                <1>         MOV     AL,"\"
   210 00000147 E8(0000)            <1>         invoke  OUTT            ;Print the CANCEL indicator
   211 0000014A 5E                  <1>         POP     SI              ;Remember start of edit buffer
   212                              <1> PUTNEW:
   213 0000014B E81701              <1>         invoke  CRLF            ;Go to next line on screen
   214 0000014E 36A0[0000]          <1>         MOV     AL,[ss:STARTPOS]
   215 00000152 E8(0000)            <1>         invoke  TAB             ;Tab over
   216 00000155 E939FF              <1>         JMP     NEWLIN          ;Start over again
   217                              <1> 
   218                              <1> 
   219                              <1> ;
   220                              <1> ; Destructively back up one character position
   221                              <1> ;
   222                              <1> entry   BackSp
   223 00000158 E80300              <1>         Call    BackSpace
   224 0000015B E94FFF              <1>         JMP     GetCh
   225                              <1> 
   226                              <1> BackSpace:
   227 0000015E 08F6                <1>         OR      DH,DH
   228 00000160 7419                <1>         JZ      OLDBAK          ;No chars in line, do nothing to line
   229 00000162 E85800              <1>         CALL    BACKUP          ;Do the backup
   230 00000165 268A05              <1>         MOV     AL,[ES:DI]      ;Get the deleted char
   231 00000168 3C20                <1>         CMP     AL," "
   232 0000016A 730F                <1>         JAE     OLDBAK          ;Was a normal char
   233 0000016C 3C09                <1>         CMP     AL,c_HT
   234 0000016E 741B                <1>         JZ      BAKTAB          ;Was a tab, fix up users display
   235                              <1> ;; 9/27/86 fix for ctrl-U backspace
   236 00000170 3C15                <1>         CMP     AL,"U"-"@"      ; ctrl-U is a section symbol not ^U
   237 00000172 7407                <1>         JZ      OLDBAK
   238 00000174 3C14                <1>         CMP     AL,"T"-"@"      ; ctrl-T is a paragraphs symbol not ^T
   239 00000176 7403                <1>         JZ      OLDBAK
   240                              <1> ;; 9/27/86 fix for ctrl-U backspace
   241 00000178 E84500              <1>         CALL    BACKMES         ;Was a control char, zap the '^'
   242                              <1> OLDBAK:
   243 0000017B 36803E[0000]00      <1>         CMP     BYTE PTR [ss:INSMODE],0
   244 00000181 7593                <1>         retnz                   ;In insert mode, done
   245 00000183 08FF                <1>         OR      BH,BH
   246 00000185 748F                <1>         retz                    ;Not advanced in template, stay where we are
   247 00000187 FECF                <1>         DEC     BH              ;Go back in template
   248 00000189 4E                  <1>         DEC     SI
   249 0000018A C3                  <1>         return
   250                              <1> 
   251                              <1> BAKTAB:
   252 0000018B 57                  <1>         PUSH    DI
   253 0000018C 4F                  <1>         DEC     DI              ;Back up one char
   254 0000018D FD                  <1>         STD                     ;Go backward
   255 0000018E 88F1                <1>         MOV     CL,DH           ;Number of chars currently in line
   256 00000190 B020                <1>         MOV     AL," "
   257 00000192 53                  <1>         PUSH    BX
   258 00000193 B307                <1>         MOV     BL,7            ;Max
   259 00000195 E30E                <1>         JCXZ    FIGTAB          ;At start, do nothing
   260                              <1> FNDPOS:
   261 00000197 AE                  <1>         SCASB                   ;Look back
   262 00000198 7609                <1>         JNA     CHKCNT
   263 0000019A 26807D0109          <1>         CMP     BYTE PTR [ES:DI+1],9
   264 0000019F 7409                <1>         JZ      HAVTAB          ;Found a tab
   265 000001A1 FECB                <1>         DEC     BL              ;Back one char if non tab control char
   266                              <1> CHKCNT:
   267 000001A3 E2F2                <1>         LOOP    FNDPOS
   268                              <1> FIGTAB:
   269 000001A5 362A1E[0000]        <1>         SUB     BL,[ss:STARTPOS]
   270                              <1> HAVTAB:
   271 000001AA 28F3                <1>         SUB     BL,DH
   272 000001AC 00D9                <1>         ADD     CL,BL
   273 000001AE 80E107              <1>         AND     CL,7            ;CX has correct number to erase
   274 000001B1 FC                  <1>         CLD                     ;Back to normal
   275 000001B2 5B                  <1>         POP     BX
   276 000001B3 5F                  <1>         POP     DI
   277 000001B4 74C5                <1>         JZ      OLDBAK          ;Nothing to erase
   278                              <1> TABBAK:
   279 000001B6 E80700              <1>         invoke  BACKMES
   280 000001B9 E2FB                <1>         LOOP    TABBAK          ;Erase correct number of chars
   281 000001BB EBBE                <1>         JMP     SHORT OLDBAK
   282                              <1> 
   283                              <1> BACKUP:
   284 000001BD FECE                <1>         DEC     DH              ;Back up in line
   285 000001BF 4F                  <1>         DEC     DI
   286                              <1> BACKMES:
   287 000001C0 B008                <1>         MOV     AL,c_BS         ;Backspace
   288 000001C2 E8(0000)            <1>         invoke  OUTT
   289 000001C5 B020                <1>         MOV     AL," "          ;Erase
   290 000001C7 E8(0000)            <1>         invoke  OUTT
   291 000001CA B008                <1>         MOV     AL,c_BS         ;Backspace
   292 000001CC E9(0000)            <1>         JMP     OUTT            ;Done
   293                              <1> 
   294                              <1> ;User really wants an ESC character in his line
   295                              <1>         entry   TwoEsc
   296 000001CF 36A0[0000]          <1>         MOV     AL,[ss:ESCCHAR]
   297 000001D3 E904FF              <1>         JMP     SAVCH
   298                              <1> 
   299                              <1> ;Copy the rest of the template
   300                              <1>         entry   COPYLIN
   301 000001D6 88D9                <1>         MOV     CL,BL           ;Total size of template
   302 000001D8 28F9                <1>         SUB     CL,BH           ;Minus position in template, is number to move
   303 000001DA EB07                <1>         JMP     SHORT COPYEACH
   304                              <1> 
   305                              <1>         entry   CopyStr
   306 000001DC E83400              <1>         invoke  FINDOLD         ;Find the char
   307 000001DF EB02                <1>         JMP     SHORT COPYEACH  ;Copy up to it
   308                              <1> 
   309                              <1> ;Copy one char from template to line
   310                              <1>         entry   COPYONE
   311 000001E1 B101                <1>         MOV     CL,1
   312                              <1> ;Copy CX chars from template to line
   313                              <1> COPYEACH:
   314 000001E3 36C606[0000]00      <1>         MOV     BYTE PTR [ss:INSMODE],0    ;All copies turn off insert mode
   315 000001E9 38D6                <1>         CMP     DH,DL
   316 000001EB 740F                <1>         JZ      GETCH2                  ;At end of line, can't do anything
   317 000001ED 38DF                <1>         CMP     BH,BL
   318 000001EF 740B                <1>         JZ      GETCH2                  ;At end of template, can't do anything
   319 000001F1 AC                  <1>         LODSB
   320 000001F2 AA                  <1>         STOSB
   321 000001F3 E8(0000)            <1>         invoke  BUFOUT
   322 000001F6 FEC7                <1>         INC     BH                      ;Ahead in template
   323 000001F8 FEC6                <1>         INC     DH                      ;Ahead in line
   324 000001FA E2E7                <1>         LOOP    COPYEACH
   325                              <1> GETCH2:
   326 000001FC E9AEFE              <1>         JMP     GETCH
   327                              <1> 
   328                              <1> ;Skip one char in template
   329                              <1>         entry   SKIPONE
   330 000001FF 38DF                <1>         CMP     BH,BL
   331 00000201 74F9                <1>         JZ      GETCH2                  ;At end of template
   332 00000203 FEC7                <1>         INC     BH                      ;Ahead in template
   333 00000205 46                  <1>         INC     SI
   334 00000206 E9A4FE              <1>         JMP     GETCH
   335                              <1> 
   336                              <1>         entry   SKIPSTR
   337 00000209 E80700              <1>         invoke  FINDOLD                 ;Find out how far to go
   338 0000020C 01CE                <1>         ADD     SI,CX                   ;Go there
   339 0000020E 00CF                <1>         ADD     BH,CL
   340 00000210 E99AFE              <1>         JMP     GETCH
   341                              <1> 
   342                              <1> ;Get the next user char, and look ahead in template for a match
   343                              <1> ;CX indicates how many chars to skip to get there on output
   344                              <1> ;NOTE: WARNING: If the operation cannot be done, the return
   345                              <1> ;       address is popped off and a jump to GETCH is taken.
   346                              <1> ;       Make sure nothing extra on stack when this routine
   347                              <1> ;       is called!!! (no PUSHes before calling it).
   348                              <1> FINDOLD:
   349 00000213 E8EAFD              <1>         invoke  D_STD_CON_INPUT_NO_ECHO
   350 00000216 363A06[0000]        <1>         CMP     AL,[ss:ESCCHAR]            ; did he type a function key?
   351 0000021B 7506                <1>         JNZ     FindSetup               ; no, set up for scan
   352 0000021D E8E0FD              <1>         invoke  D_STD_CON_INPUT_NO_ECHO  ; eat next char
   353                              <1> NotFnd equ NOTFND	; NASM port label
   354 00000220 EB1E                <1>         JMP     NotFnd                  ; go try again
   355 00000222 90                  <1> 	nop	; identicalise
   356                              <1> FindSetup:
   357 00000223 88D9                <1>         MOV     CL,BL
   358 00000225 28F9                <1>         SUB     CL,BH           ;CX is number of chars to end of template
   359 00000227 7417                <1>         JZ      NOTFND          ;At end of template
   360 00000229 49                  <1>         DEC     CX              ;Cannot point past end, limit search
   361 0000022A 7414                <1>         JZ      NOTFND          ;If only one char in template, forget it
   362 0000022C 06                  <1>         PUSH    ES
   363 0000022D 1E                  <1>         PUSH    DS
   364 0000022E 07                  <1>         POP     ES
   365                              <1>  assume es:nothing
   366 0000022F 57                  <1>         PUSH    DI
   367 00000230 89F7                <1>         MOV     DI,SI           ;Template to ES:DI
   368 00000232 47                  <1>         INC     DI
   369 00000233 F2AE                <1>         REPNE   SCASB           ;Look
   370 00000235 5F                  <1>         POP     DI
   371 00000236 07                  <1>         POP     ES
   372                              <1>  assume es:nothing
   373 00000237 7507                <1>         JNZ     NOTFND          ;Didn't find the char
   374 00000239 F6D1                <1>         NOT     CL              ;Turn how far to go into how far we went
   375 0000023B 00D9                <1>         ADD     CL,BL           ;Add size of template
   376 0000023D 28F9                <1>         SUB     CL,BH           ;Subtract current pos, result distance to skip
   377 0000023F C3                  <1>         return
   378                              <1> 
   379                              <1> NOTFND:
   380 00000240 5D                  <1>         POP     BP              ;Chuck return address
   381 00000241 E969FE              <1>         JMP     GETCH
   382                              <1> 
   383                              <1> entry   REEDIT
   384 00000244 B040                <1>         MOV     AL,"@"          ;Output re-edit character
   385 00000246 E8(0000)            <1>         invoke  OUTT
   386 00000249 5F                  <1>         POP     DI
   387 0000024A 57                  <1>         PUSH    DI
   388 0000024B 06                  <1>         PUSH    ES
   389 0000024C 1E                  <1>         PUSH    DS
   390 0000024D E8BBFE              <1>         invoke  COPYNEW         ;Copy current line into template
   391 00000250 1F                  <1>         POP     DS
   392                              <1>  assume ds:nothing
   393 00000251 07                  <1>         POP     ES
   394                              <1>  assume es:nothing
   395 00000252 5E                  <1>         POP     SI
   396 00000253 88F3                <1>         MOV     BL,DH           ;Size of line is new size template
   397 00000255 E9F3FE              <1>         JMP     PUTNEW          ;Start over again
   398                              <1> 
   399                              <1>         entry   EXITINS
   400                              <1>         entry   ENTERINS
   401 00000258 36F616[0000]        <1>         NOT     BYTE PTR [ss:INSMODE]
   402 0000025D E94DFE              <1>         JMP     GETCH
   403                              <1> 
   404                              <1> ;Put a real live ^Z in the buffer (embedded)
   405                              <1>         entry   CTRLZ
   406 00000260 B01A                <1>         MOV     AL,"Z"-"@"
   407 00000262 E975FE              <1>         JMP     SAVCH
   408                              <1> 
   409                              <1> ;Output a CRLF
   410                              <1>         entry   CRLF
   411 00000265 B00D                <1>         MOV     AL,c_CR
   412 00000267 E8(0000)            <1>         invoke  OUTT
   413 0000026A B00A                <1>         MOV     AL,c_LF
   414 0000026C E9(0000)            <1>         JMP     OUTT
   415                              <1> 
   416                              <1> EndProc D_STD_CON_STRING_INPUT
   417                              <1> 
   418                              <1> 
   239                                  ;=== Pop trace listing source
   240                                  %ENDIF					;AN000;
   241                                  
   242                                  Break
   243                                  
   244                                  ; Inputs:
   245                                  ;	DL = -1 if input
   246                                  ;	else DL is output character
   247                                  ; Function:
   248                                  ;	Input or output raw character from console, no echo
   249                                  ; Returns:
   250                                  ;	AL = character
   251                                  
   252                                  	procedure   D_RAW_CON_IO,NEAR   ; System call 6
   252          ******************       warning: proc D_RAW_CON_IO... [-w+user]
   253                                  ASSUME	DS:NOTHING,ES:NOTHING
   254                                  
   255 0000026F 88D0                    	MOV	AL,DL
   256 00000271 3CFF                    	CMP	AL,-1
   257 00000273 7403                    	JZ	RAW22				      ;AN000;
   258 00000275 EB43                    	JMP	RAWOUT				      ;AN000;
   259 00000277 90                      	nop	; identicalise
   260                                  RAW22:						      ;AN000;
   261 00000278 36C43E[0000]            	LES	DI,[ss:user_SP]		      ; Get pointer to register save area
   262 0000027D 31DB                    	XOR	BX,BX
   263 0000027F E8(0000)                	invoke	GET_IO_SFT
   264 00000282 72BB                    	retc
   265                                   %IF  DBCS				;AN000;
   266                                  Intercon equ InterCon	; NASM port label
   267                                  	push	word ptr [Intercon]	;AN000;
   268                                  	mov	byte [Intercon],0		;AN000; disable interim characters
   269                                   %ENDIF					;AN000;
   270 00000284 B401                    	MOV	AH,1
   271 00000286 E8(0000)                	invoke	IOFUNC
   272 00000289 750B                    	JNZ	RESFLG
   273                                   %IF  DBCS				;AN000;
   274                                  	pop	word ptr [InterCon]	;AN000; restore interim flag
   275                                   %ENDIF					;AN000;
   276 0000028B E8(0000)                	invoke	SPOOLINT
   277 0000028E 26804D1640              	OR	BYTE PTR [ES:DI + user_F],40H ; Set user's zero flag
   278 00000293 30C0                    	XOR	AL,AL
   279 00000295 C3                      	return
   280                                  
   281                                  RESFLG:
   282 00000296 26806516BF              	AND	BYTE PTR [ES:DI + user_F],0FFH-40H    ; Reset user's zero flag
   283                                   %IF  DBCS				;AN000;
   284                                  	XOR	AH,AH			;AN000;
   285                                  	invoke	IOFUNC			;AN000; get the character
   286                                  	pop	word ptr [InterCon]	;AN000;
   287                                  	return				;AN000;
   288                                   %ENDIF					;AN000; 				;AN000;
   289                                  
   290                                  RILP:
   291 0000029B E8(0000)                	invoke	SPOOLINT
   292                                  
   293                                  ; Inputs:
   294                                  ;	None
   295                                  ; Function:
   296                                  ;	Input raw character from console, no echo
   297                                  ; Returns:
   298                                  ;	AL = character
   299                                  
   300                                  	entry	D_RAW_CON_INPUT	      ; System call 7
   301                                  
   302 0000029E 53                      	PUSH	BX
   303 0000029F 31DB                    	XOR	BX,BX
   304 000002A1 E8(0000)                	invoke	GET_IO_SFT
   305 000002A4 5B                      	POP	BX
   306 000002A5 72EE                    	retc
   307 000002A7 B401                    	MOV	AH,1
   308 000002A9 E8(0000)                	invoke	IOFUNC
   309 000002AC 7506                    	JNZ	Got
   310 000002AE B484                    	MOV	AH,84h
   311 000002B0 CD2A                    	INT	int_IBM
   312 000002B2 EBE7                    	JMP	RILP
   313                                  Got:
   314 000002B4 30E4                    	XOR	AH,AH
   315 000002B6 E8(0000)                	invoke	IOFUNC
   316                                   %IF  DBCS				;AN000;
   317                                  	cmp	byte [InterChar],1		;AN000;    2/11/KK
   318                                  ;								2/11/KK
   319                                  ;	Sets the application zero flag depending on the 	2/11/KK
   320                                  ;	zero flag upon entry to this routine. Then returns	2/11/KK
   321                                  ;	from system call.					2/11/KK
   322                                  ;								2/11/KK
   323                                  entry	InterApRet			;AN000; 		2/11/KK 	;AN000;
   324                                  	pushf				;AN000; 3/16/KK
   325                                  	push	ds			;AN000; 3/16/KK
   326                                  	push	bx			;AN000; 3/16/KK
   327                                  	Context DS			;AN000; 3/16/KK
   328                                  	MOV	BX,offset COUNTRY_CDPG.ccDosCodePage wrt DOSGROUP
   329                                  	cmp	word ptr [bx],934	;AN000; 3/16/KK       korean code page ?
   330                                  	pop	bx			;AN000; 3/16/KK
   331                                  	pop	ds			;AN000; 3/16/KK
   332                                  	je	do_koren		;AN000; 3/16/KK
   333                                  	popf				;AN000; 3/16/KK
   334                                  	return				;AN000; 3/16/KK
   335                                  do_koren:				;AN000; 3/16/KK
   336                                  	popf				;AN000;
   337                                  	LES	DI,[user_SP]	;AN000; Get pointer to register save area KK
   338                                  	jnz	sj0			;AN000; 		      2/11/KK
   339                                  	OR	BYTE PTR [ES:DI + user_F],40H	;AN000; Set user's zero flag  2/11/KK
   340                                  	return				;AN000; 		2/11/KK
   341                                  sj0:					;AN000; 		2/11/KK
   342                                  	AND	BYTE PTR [ES:DI + user_F],0FFH-40H ;AN000; Reset user's zero flag 2/KK
   343                                   %ENDIF						 ;AN000;
   344 000002B9 C3                      	return					 ;AN000;
   345                                  ;
   346                                  ;	Output the character in AL to stdout
   347                                  ;
   348                                  	entry	RAWOUT
   349                                  
   350 000002BA 53                      	PUSH	BX
   351 000002BB BB0100                  	MOV	BX,1
   352                                  
   353 000002BE E8(0000)                	invoke	GET_IO_SFT
   354 000002C1 721B                    	JC	RAWRET1
   355                                  
   356 000002C3 8B5C05                  	MOV	BX,[SI + sf_flags]
   357                                  
   358                                   ;
   359                                   ; If we are a network handle OR if we are not a local device then go do the
   360                                   ; output the hard way.
   361                                   ;
   362                                  
   363                                  sf_isNet equ sf_isnet	; NASM port equate
   364 000002C6 81E38080                	AND	BX,sf_isNet + devid_device
   365 000002CA 81FB8000                	CMP	BX,devid_device
   366                                  RawNorm equ RAWNORM	; NASM port label
   367 000002CE 7510                    	JNZ	RawNorm
   368                                   %IF  DBCS					;AN000;
   369                                  	TEST	byte [SaveCurFlg],01H		;AN000; print but no cursor adv?
   370                                  	JNZ	RAWNORM 			;AN000;    2/11/KK
   371                                   %ENDIF						;AN000;
   372                                  
   373                                  ;	TEST	BX,sf_isnet			; output to NET?
   374                                  ;	JNZ	RAWNORM 			; if so, do normally
   375                                  ;	TEST	BX,devid_device 		; output to file?
   376                                  ;	JZ	RAWNORM 			; if so, do normally
   377                                  
   378 000002D0 1E                      	PUSH	DS
   379 000002D1 C55C07                  	LDS	BX,[SI + sf_devptr]		; output to special?
   380                                   assume ds:nothing
   381 000002D4 F6470410                	TEST	BYTE PTR [BX+SDEVATT],ISSPEC
   382 000002D8 1F                      	POP	DS
   383                                   assume ds:nothing
   384 000002D9 7405                    	JZ	RAWNORM 			; if not, do normally
   385 000002DB CD29                    	INT	int_fastcon			; quickly output the char
   386                                  RAWRET:
   387 000002DD F8                      	CLC
   388                                  RAWRET1:
   389 000002DE 5B                      	POP	BX
   390 000002DF C3                      	return
   391                                  RAWNORM:
   392 000002E0 E80700                  	CALL	RAWOUT3
   393 000002E3 EBF8                    	JMP	RAWRET
   394                                  
   395                                  ;
   396                                  ;	Output the character in AL to handle in BX
   397                                  ;
   398                                  	entry	RAWOUT2
   399                                  
   400 000002E5 E8(0000)                	invoke	GET_IO_SFT
   401 000002E8 72F5                    	retc
   402                                  RAWOUT3:
   403 000002EA 50                      	PUSH	AX
   404 000002EB EB0D                    	JMP	SHORT RAWOSTRT
   405                                  ROLP:
   406 000002ED E8(0000)                	invoke	SPOOLINT
   407 000002F0 36810E[0000]0002        	OR	word [ss:DOS34_FLAG],CTRL_BREAK_FLAG ;AN002; set control break
   408 000002F7 E8(0000)                	invoke	DSKSTATCHK		     ;AN002; check control break
   409                                  RAWOSTRT:
   410 000002FA B403                    	MOV	AH,3
   411 000002FC E8(0000)                	invoke	IOFUNC
   412 000002FF 74EC                    	JZ	ROLP
   413 00000301 58                      	POP	AX
   414 00000302 B402                    	MOV	AH,2
   415 00000304 E8(0000)                	invoke	IOFUNC
   416 00000307 F8                      	CLC			; Clear carry indicating successful
   417 00000308 C3                      	return
   418                                  EndProc D_RAW_CON_IO
   419                                  
   420                                  ; Inputs:
   421                                  ;	AX=0 save the DEVCALL request packet
   422                                  ;	  =1 restore the DEVCALL request packet
   423                                  ; Function:
   424                                  ;	save or restore the DEVCALL packet
   425                                  ; Returns:
   426                                  ;	none
   427                                  
   428                                  	procedure   Save_Restore_Packet,NEAR
   428          ******************       warning: proc Save_Restore_Packet... [-w+user]
   429                                  ASSUME	DS:NOTHING,ES:NOTHING
   430                                  
   431 00000309 1E                      	PUSH	DS
   432 0000030A 06                      	PUSH	ES
   433 0000030B 56                      	PUSH	SI
   434 0000030C 57                      	PUSH	DI
   435 0000030D 83F800                  	CMP	AX,0		; save packet
   436 00000310 7409                    	JZ	save_packet
   437                                  restore_packet:
   438 00000312 BE[0000]                	MOV	SI,OFFSET Packet_Temp wrt DOSGROUP	 ;sourec
   439 00000315 BF[0000]                	MOV	DI,OFFSET DEVCALL wrt DOSGROUP	 ;destination
   440 00000318 EB07                    	JMP	set_seg
   441 0000031A 90                      	nop	; identicalise
   442                                  save_packet:
   443 0000031B BF[0000]                	MOV	DI,OFFSET Packet_Temp wrt DOSGROUP	 ;destination
   444 0000031E BE[0000]                	MOV	SI,OFFSET DEVCALL wrt DOSGROUP	 ;source
   445                                  set_seg:
   446 00000321 8CD0                    	MOV	AX,ss		; set DS,ES to DOSGROUP
   447 00000323 8ED8                    	MOV	DS,AX
   448 00000325 8EC0                    	MOV	ES,AX
   449                                   assume ds:DOSGROUP, es:DOSGROUP
   450 00000327 B90B00                  	MOV	CX,11		; 11 words to move
   451 0000032A F3A5                    	REP	MOVSW
   452                                  
   453 0000032C 5F                      	POP	DI
   454 0000032D 5E                      	POP	SI
   455 0000032E 07                      	POP	ES
   456 0000032F 1F                      	POP	DS
   457                                   assume ds:nothing, es:nothing
   458 00000330 C3                      	return
   459                                  EndProc Save_Restore_Packet
   460                                  
   461                                      END
