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

📄 rxdoscmd.asm

📁 dos source
💻 ASM
📖 第 1 页 / 共 5 页
字号:
        TITLE   'Cmd - RxDOS Command Shell'
        PAGE 59, 132
        .LALL

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  RxDOS Command Shell                                          ;
        ;...............................................................;

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Real Time Dos                                                ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  This material  was created as a published version  of a DOS  ;
        ;  equivalent product.   This program  logically  functions in  ;
        ;  the same way as  MSDOS functions and it  is  internal  data  ;
        ;  structure compliant with MSDOS 6.0                           ;
        ;                                                               ;
        ;  This product is distributed  AS IS and contains no warranty  ;
        ;  whatsoever,   including  warranty  of   merchantability  or  ;
        ;  fitness for a particular purpose.                            ;
        ;                                                               ;
        ;                                                               ;
        ;  (c) Copyright 1990, 1997. Api Software and Mike Podanoffsky  ;
        ;      All Rights Reserved Worldwide.                           ;
        ;                                                               ;
        ;  This product is protected under copyright laws and  may not  ;
        ;  be reproduced  in whole  or in part, in any form  or media,  ;
        ;  included but not limited to source listing, facsimile, data  ;
        ;  transmission, cd-rom, or  floppy disk without the expressed  ;
        ;  written consent of the author.                               ;
        ;                                                               ;
        ;  License  for  distribution  for commercial  use  or  resale  ;
        ;  required from:                                               ;
        ;                                                               ;
        ;  Api Software                                                 ;
        ;  12 South Walker Street                                       ;
        ;  Lowell,  MA   01851                                          ;
        ;                                                               ;
        ;  internet: mikep@world.std.com                                ;
        ;                                                               ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;  Compile with MASM 5.1                                        ;
        ;...............................................................;

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  RxDOS Command Shell                                          ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Programmer's Notes:                                          ;
        ;                                                               ;
        ;  Command Shell consists of  two parts bound  together into a  ;
        ;  single executable load.  There  exists  a  single  resident  ;
        ;  command shell which is accessible by an Int 2Eh.             ;
        ;                                                               ;
        ;...............................................................;

        include rxdosmac.asm
        include rxdosdef.asm
        include rxdoscin.asm

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Execution Control                                            ;
        ;...............................................................;

        EXECCONTROL struc

exCtrlArgArray                  dd ?
exCtrlStdInHandle               dw ?
exCtrlStdOutHandle              dw ?

exCtrlFlags                     dw ?
exCtrlStdInFileName             db sizeEXPANDNAME dup(?)
exCtrlStdOutFileName            db sizeEXPANDNAME dup(?)
exCtrlExecBlock                 db sizeEXEC dup(?)

        EXECCONTROL ends

exCtrlPiped                     equ 8000h
exCtrlAppend                    equ 4000h               ; append to stdout
exTempInputFile                 equ 2000h               ; temp stdin created

sizeEXECCONTROL                 equ size EXECCONTROL
maxArgArray                     equ 64 

_BAT                            equ 0
_EXE                            equ 1
_COM                            equ 2

DYNAMIC_BUFFERSIZE              equ 4 * 1024            ; cannot exceed stack

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  If Special Values                                            ;
        ;...............................................................;

IF_NOT                          equ 01h
IF_ERRORLEVEL                   equ 02h
IF_EXIST                        equ 03h

_ARGTEXT                        equ _high
_ARGTYPE                        equ _low

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  RxDOS Command Shell                                          ;
        ;...............................................................;

        public CommandBegin

RxDOSCMD SEGMENT PARA PUBLIC 'CODE'
         assume cs:RxDOSCMD, ds:RxDOSCMD, es:RxDOSCMD, ss:RxDOSCMD

        org 100h

        public CheckOptOneArg
        public CmndError_BadSwitch
        public CmndError_CannotCopyUntoSelf
        public CmndError_CannotCreateFile
        public CmndError_ContentsLostBeforeCopy
        public CmndError_FileAlreadyExists
        public CmndError_FileNotFound
        public CmndError_InvalidDate
        public CmndError_InvalidDrive
        public CmndError_InvalidTime
        public CmndError_NoFilesFound
        public CmndError_SyntaxError
        public CmndError_InvalidNumberArguments
        public CmndError_OutOfEnvironmentSpace

        public CRLF
        public CmndLookup
        public _Copy_FilesCopied
        public CountArgs

        public deleteArg
        public deleteEnvVariable
        public DisplayErrorCode
        public DisplayErrorMessage
        public DisplayOutEnvSpace
        public DisplayLine
        public insertEnvVariable
        public PreProcessCmndLine
        public ReplaceForVariables
        public returnVolumeName
        public searchEnvVariable
        public setPagingMode

        public RxDOSIntl_DateTemplate
        public RxDOSIntl_DayOfWeek
        public RxDOSIntl_TimeTemplate
        public RxDOSIntl_DateTimeTable

        public RxDOS_AllFiles
        public RxDOS_DefaultPrompt
        public RxDOS_DTA
        public RxDOS_ForArgs
        public RxDOS_Prompt
        public RxDOS_PromptSpec
        public RxDOS_Version

        public _AppendPathName
        public _CmndParse_SeparatorCheck
        public _CopyString
        public _DirAttribSwitch
        public _DirBareSwitch
        public _DirLowerCaseSwitch
        public _DirOrderSwitch
        public _DirPauseSwitch
        public _DirSubDirSwitch
        public _DirSwitches
        public _DirWideSwitch
        public _Dir_DirectoryOf
        public _Dir_DirEntry
        public _Dir_FileEntry
        public _Dir_Files
        public _Dir_NoVolumeLabel
        public _Dir_VolumeLabel
        public _Dir_VolumeSerialNumber
        public _endofString
        public _EnvSegment
        public _GetNumber
        public _getStdinLine
        public _CommandParser
        public _lowerCase
        public _lowerCaseString
        public _PleaseEnterDate
        public _PleaseEnterTime
        public _ShowCurrentDate
        public _ShowCurrentTime
        public _sprintf
        public _SwitchChar
        public _computeLength
        public _Seeif_WildCharacter

    ; in rxdoscpy.asm

        extrn _Copy                                     : near

    ; in rxdosdir.asm

        extrn _Dir                                      : near

    ; in rxdosfor.asm

        extrn _For                                      : near

    ; in rxdosprm.asm

        extrn _Prompt                                   : near
        extrn _Date                                     : near
        extrn _Time                                     : near

        extrn DisplayPrompt                             : near
        extrn formatCurrentDate                         : near
        extrn formatCurrentTime                         : near

    ; in rxdosren.asm

        extrn _Rename                                   : near
        extrn RXDOSLASTADDRESS                          : near

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  RxDOS Command Parser/ Execute                                ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  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.                                                    ;
        ;                                                               ;
        ;...............................................................;

_CommandParser  PROC FAR

        Entry
        ddef _OriginalCmdLine, ds, si                   ; argument is copied
        defbytes _commandLine, 128                      ; argument is copied
        defwords __argarray, maxArgArray                ; argument array
                                                        ; (last arg is null)
        SaveAllRegisters                                ; save all registers
        cld                                             ; and direction

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  get switch character
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        Int21 GetSetSwitchChar, 00                      ; get switch char
        mov byte ptr cs:[ _SwitchChar ], dl             ; save switch character

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  copy command line 
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        getdarg ds, si, _OriginalCmdLine

        lodsb 
        mov cl, al                                      ; length
        xor ch, ch
        or cx, cx                                       ; any arguments ?
        jz _commandParser_36                            ; if no arguments -->

        setES cs
        lea di, offset [ _commandLine ][ bp ]
        rep movsb                                       ; copy command line
        
        xor ax, ax
        stosb                                           ; add a null terminator

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  parse
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

        setDS cs        
        mov cx, maxArgArray - 2                         ; # argument array entries
        lea si, offset [ _commandLine ][ bp ]
        lea di, offset [ __argarray   ][ bp ]
        call _BuildArgArray                             ; break up into arg list
        jz _CommandParser_36                            ; if no arguments -->

        mov si, word ptr [ __argarray ][ bp ]           ; get lead argument
        cmp byte ptr [ si ], ':'                        ; label line ?
        jz _CommandParser_36                            ; ignore -->

        lea di, offset [ __argarray   ][ bp ]
        call _executeCommandArray
        
        cmp byte ptr [ _EchoStatus ], No                ; echo ?
        jz _CommandParser_36                            ; if no echo -->
        call CRLF

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  command completed
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

⌨️ 快捷键说明

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