Subversion Repositories SvarDOS

Rev

Rev 519 | Rev 538 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 519 Rev 520
Line 109... Line 109...
109
      mov bx, 1          /* access mode (0=read, 1=write, 2=r+w */
109
      mov bx, 1          /* access mode (0=read, 1=write, 2=r+w */
110
      xor cx, cx         /* attributes when(if) creating the file (0=normal) */
110
      xor cx, cx         /* attributes when(if) creating the file (0=normal) */
111
      mov dx, [openflag] /* action if file exists (0x11=open, 0x12=truncate)*/
111
      mov dx, [openflag] /* action if file exists (0x11=open, 0x12=truncate)*/
112
      mov si, myptr      /* ASCIIZ filename */
112
      mov si, myptr      /* ASCIIZ filename */
113
      int 0x21           /* AX=handle on success (CF clear), otherwise dos err */
113
      int 0x21           /* AX=handle on success (CF clear), otherwise dos err */
114
      mov [handle], ax   /* save the file handler */
114
      mov handle, ax     /* save the file handler */
115
      jnc DUPSTDOUT
115
      jnc JMPEOF
116
      mov [errcode], ax
116
      mov errcode, ax
117
      jmp DONE
117
      jmp DONE
-
 
118
 
-
 
119
      JMPEOF:
-
 
120
      cmp openflag, word ptr 0x11
118
      DUPSTDOUT:
121
      jne DUPSTDOUT
-
 
122
      /* jump to the end of the file (required for >> redirections) */
-
 
123
      mov ax, 0x4202     /* jump to position EOF - CX:DX in handle BX */
-
 
124
      mov bx, handle
-
 
125
      xor cx, cx
-
 
126
      xor dx, dx
-
 
127
      int 0x21
-
 
128
 
119
      /* save (duplicate) current stdout so I can revert it later */
129
      /* save (duplicate) current stdout so I can revert it later */
-
 
130
      DUPSTDOUT:
120
      mov ah, 0x45       /* duplicate file handle */
131
      mov ah, 0x45       /* duplicate file handle */
121
      mov bx, 1          /* handle to dup (1=stdout) */
132
      mov bx, 1          /* handle to dup (1=stdout) */
122
      int 0x21           /* ax = new file handle */
133
      int 0x21           /* ax = new file handle */
123
      mov [oldstdout], ax
134
      mov oldstdout, ax
124
      /* redirect the stdout handle */
135
      /* redirect the stdout handle */
125
      mov bx, [handle]   /* dst handle */
136
      mov bx, handle     /* dst handle */
126
      mov cx, 1          /* src handle (1=stdout) */
137
      mov cx, 1          /* src handle (1=stdout) */
127
      mov ah, 0x46       /* redirect a handle */
138
      mov ah, 0x46       /* redirect a handle */
128
      int 0x21
139
      int 0x21
129
      /* close the original file handle (no longer needed) */
140
      /* close the original file handle (no longer needed) */
130
      mov ah, 0x3e       /* close a file handle (handle in BX) */
141
      mov ah, 0x3e       /* close a file handle (handle in BX) */