⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rxdoscmd.asm

📁 dos source
💻 ASM
📖 第 1 页 / 共 5 页
字号:

_CommandParser_36:
        restoreAllRegisters
        Return

_CommandParser  ENDP

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  RxDOS Command Parser/ Execute                                ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Usage:                                                       ;
        ;   ds:si  command line beginning with a count                  ;
        ;          (this fct does not rely on CR at end of buffer)      ;
        ;                                                               ;
        ;...............................................................;

_Int2E_CommandParser  PROC FAR

        push ds
        push si
        mov si, ss
        mov ds, si
        mov si, sp                                      ; old stack to ds: si

        cld
        cli
        setSS cs
        mov sp, offset RxDOS_AltStack                   ; switch stacks
        sti

        saveRegisters ds, si                            ; save pointer to other stack
        lds si, dword ptr [ si ]                        ; restore old ds:si values.
        call _CommandParser                             ; call command parser

        cli
        pop si
        pop ss    
        mov sp, si                                      ; back to old stack.
        sti

        pop si
        pop ds                                          ; restore ds: si values

        iret
_Int2E_CommandParser  ENDP

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Control C Interrupt Service Routine                          ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Usage:                                                       ;
        ;   ds:si  command line beginning with a count                  ;
        ;          (this fct does not rely on CR at end of buffer)      ;
        ;                                                               ;
        ;   The command is executed, which may require loading another  ;
        ;   program.                                                    ;
        ;                                                               ;
        ;...............................................................;

_ControlC_ISR   PROC FAR

        Int21 GetPSPAddress
        cmp bx, word ptr cs:[ _PSPSegment ]             ; current cmd processor copy ?
        jz _ControlC_ISR_12                             ; yes, accept ctlC -->

        stc
        ret 2                                           ; cause abort

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  abort current command, batch files
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

_ControlC_ISR_12:
        cli
        mov ax, cs
        mov ds, ax
        mov es, ax
        mov ss, ax
        mov sp, word ptr [ RxDOS_PrevStackFrame ]       ; current stack frame
        sti

_ControlC_ISR_16:
        cmp word ptr [ RxDOS_BatchFile. batchFileHandle ], 0000
        jz _ControlC_ISR_24                             ; if not running a batch file -->

        call _EndCall                                   ; terminate batch file
        jmp _ControlC_ISR_16                            ; undo all nested batch calls

_ControlC_ISR_24:
        jmp CommandInput   

_ControlC_ISR   ENDP

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Execute Command Stored in Arg Array                          ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Usage:                                                       ;
        ;   ss:di  argument array                                       ;
        ;...............................................................;

_executeCommandArray:

        Entry
        def __argarray, di                              ; argument array
        def __stdin                                     ; stdin on entry
        def __stdout                                    ; stdout on entry
        
        defbytes __execCtrlBlock, sizeEXECCONTROL
        defbytes __pathArg, 128

        mov cx, STDIN
        call _assignGetCurrHandle                       ; get current handle
        storarg __stdin, ax                             ; stdin on entry

        mov cx, STDOUT
        call _assignGetCurrHandle                       ; get current handle
        storarg __stdout, ax                            ; stdout on entry

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  scan remainder of command line for pipe, stdin and stdout args
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        xor ax, ax
        lea bx, offset [ __execCtrlBlock ][ bp ]
        getarg di, __argarray                           ; argument array

        push di
        mov di, bx
        mov cx, sizeEXECCONTROL
        rep stosb                                       ; clear exec control block
        pop di

        mov dx, -1
        mov word ptr [ exCtrlStdInHandle ][ bx ], dx    ; no stdin file

_executeArray_04:
        mov dx, -1
        mov word ptr [ exCtrlStdOutHandle ][ bx ], dx   ; no stdout file (stdin may have been piped)

        lea bx, offset [ __execCtrlBlock ][ bp ]
        call _assignRedirectedDevices                   ; arg array in [di]

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  see if command is valid
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        getarg di, __argarray                           ; restore pointer to arg array
        mov si, word ptr [ di ]                         ; get lead argument
        call checkInstallableCommandInterface           ; command executed ?
        jnz _executeArray_36                            ; yes -->

        getarg di, __argarray                           ; restore pointer to arg array
        mov si, word ptr [ di ]                         ; get lead argument
        mov di, offset RxDOS_InternalCommands
        call CmndLookup                                 ; lookup command
        jnc _executeArray_26                            ; if command found -->

        call checkUnixStyleCommands                     ; Unix style commands ?
        jnz _executeArray_10                            ; if no unix cmds -->

        getarg di, __argarray                           ; restore pointer to arg array
        mov si, word ptr [ di ]                         ; get lead argument
        mov di, offset RxDOS_UNIXStyleCommands
        call CmndLookup                                 ; lookup command
        jnc _executeArray_26                            ; if command found -->

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  see if valid drive letter
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

_executeArray_10:
        mov di, word ptr [ __argarray ][ bp ]           ; arguments pointer
        mov si, word ptr [ di ]                         ; get lead argument
        cmp word ptr ss:[ si+1 ], ':'                   ; disk select ?
        jnz _executeArray_12                            ; if unknown -->

        call CountArgs                                  ; count how many arguments
        call _DiskSelect                                ; process disk select
        jmp _executeArray_36

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  see if .exe, .com, or .bat (filename in ss:si )
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

_executeArray_12:
        lea dx, offset [ __PathArg ][ bp ]
        call _executeProgram                            ; try to execute program
        jc _executeArray_36                             ; if error -->

        call _saveBatchArguments                        ; if batch file, save arguments
        jmp _executeArray_36
        
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  go process command
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

_executeArray_26:
        mov di, word ptr [ __argarray ][ bp ]           ; arguments pointer
        call SplitArgs                                  ; for cd.. cases

        inc di
        inc di                                          ; argument array past arg 
        mov si, word ptr [ di ]                         ; get lead argument
        call CountArgs                                  ; count how many arguments
        call bx                                         ; go execute commands

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  done
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

_executeArray_36:
        mov byte ptr [ PageLines ], 00                  ; cancel page lines

        mov bx, STDIN
        mov ax, word ptr [ __execCtrlBlock. exCtrlStdInHandle ][ bp ]
        call _CloseRedirectedDevice

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  temp input file created ?
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        getarg di, __argarray
        test word ptr [ __execCtrlBlock. exCtrlFlags ][ bp ], exTempInputFile
        jz _executeArray_42                             ; not piped in -->

        mov bx, STDIN
        Int21 DeleteFile                                ; delete temp stdin

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  is arg piped ?
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

_executeArray_42:
        getarg di, __argarray
        test word ptr [ __execCtrlBlock. exCtrlFlags ][ bp ], exCtrlPiped
        jnz _executeArray_46

        mov bx, STDIN
        getarg ax, __stdin                              ; stdin on entry
        call _CloseRedirectedDevice                     ; close device

        mov bx, STDOUT
        getarg ax, __stdout                             ; stdout on entry
        call _CloseRedirectedDevice                     ; close device
        Return

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  arg is piped
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

_executeArray_46:
        mov ax, word ptr [ di ]
        inc di
        inc di
        or ax, ax                                       ; at end of search ?
        jnz _executeArray_46                            ; keep loopking -->

        and word ptr [ __execCtrlBlock. exCtrlFlags ][ bp ], NOT exCtrlPiped
        or word ptr [ __execCtrlBlock. exCtrlFlags ][ bp ], exTempInputFile
        storarg __argarray, di                          ; next in arg array

    ; must reopen file given by temp...
    ; maybe should not have closed it.

        mov cx, STDOUT
        call _assignGetCurrHandle                       ; get current handle
        mov word ptr [ __execCtrlBlock. exCtrlStdInHandle ][ bp ], ax

        mov bx, STDOUT
        Int21 CommitFile                                ; close stdout

        xor cx, cx
        xor dx, dx
        mov bx, STDOUT
        Int21 MoveFilePointer, SEEK_BEG                 ; point to beg of file

        mov bx, STDOUT
        mov cx, STDIN
        Int21 ForceFileHandle                           ; redirect stdout -> stdin

        mov bx, STDOUT
        mov ax, word ptr [ __execCtrlBlock. exCtrlStdOutHandle ][ bp ]
        call _CloseRedirectedDevice

        getarg di, __argarray                           ; next in arg array
        jmp _executeArray_04

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Build Argument Array                                         ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -