home *** CD-ROM | disk | FTP | other *** search
- ;**********************************************************
- ;* *
- ;* SysCm *
- ;* *
- ;* Function: Execute MS-DOS command. *
- ;* Input: DS:SI points to buffer with command *
- ;* line. *
- ;* AX == 0 - execute program *
- ;* AX == 1 - execute the second copy of *
- ;* Command.com *
- ;* Output: None. *
- ;* *
- ;* Last modification: 93-02-02 11:01. *
- ;* *
- ;* *
- ;* CopyRight 1995. Nicholas Poljakov all rights reserved.*
- ;* *
- ;**********************************************************
- .DOSSEG
- .MODEL SMALL
-
- include c:\m61\include\dos.inc
- include c:\m61\include\bios.inc
- include c:\m61\include\macros.inc
- include parms.inc
-
- EXTRN DosCom:BYTE
- EXTRN AplParm:BYTE
-
- PUBLIC params, keep_ss, keep_sp, SysCm, UpStr
-
- .DATA
-
- params DW 7 dup(0) ;¡π½Ñó«⌐ í½«¬ »áαá¼ÑΓα«ó
- keep_ss DW 0 ;»ÑαѼѡ¡á∩ ñ½∩ ss
- keep_sp DW 0 ;»ÑαѼѡ¡á∩ ñ½∩ sp
- ArgLt DB 0 ; length of next field
- argsh DB '/c '
- argst DB 60 DUP(0)
-
- .CODE
-
- SysCm PROC
- @SaveRegs ax,bx,cx,dx,ds,si,es,di,bp
- mov bp, sp
-
- ;---»«ñú«Γáó½¿óáѼ »«½Ñ »áαá¼ÑΓα«ó
-
- mov ax, ds
- mov es, ax
-
- mov di, OFFSET params
- xor ax, ax
- mov cx, 7
- cld
- rep stosw
-
- ;---ß«σαá¡¿Γ∞ ¬«»¿¿ ss ¿ sp
-
- mov keep_ss, ss ;ß«σαá¡∩Ѽ ss
- mov keep_sp, sp ;ß«σαá¡∩Ѽ sp
-
- mov ax, WORD PTR [bp + 16]
- and ax, ax
- jz ExPgm ; load and execute the program
-
- ;*
- ;* Call second copy of Command.com
- ;*
- mov dx, OFFSET DosCom
- xor ch, ch
- mov cl, BYTE PTR [si] ; length of command line
- mov di, OFFSET argst
- inc si ; skip count field
- cld
- rep movsb ; prepare arguments field
-
- mov si, WORD PTR [bp + 6] ; restore SI
- mov cl, BYTE PTR [si] ; length of command line
- add cx, 4
- mov bx, cx
- mov si, OFFSET ArgLt
- mov BYTE PTR [si + bx], 13
- inc bx
- mov BYTE PTR [si + bx], 0
- dec bx
- mov ArgLt, bl
- mov WORD PTR params + 2, si
- mov ax, ds
- mov WORD PTR params + 4, ax
- jmp short ExCall
-
- ExPgm:
- ;---π¬áºδóáѼ ¡á ßΓα«¬π ¿¼Ñ¡¿ Σá⌐½á
-
- mov dx, WORD PTR [bp + 6] ; input SI
- mov bx, OFFSET AplParm
- lea bx, ds:[bx].Args
- mov WORD PTR params + 2, bx
- mov bx, ds
- mov WORD PTR params + 4, bx
- ExCall:
- mov bx, OFFSET params
-
- ;---ºáúαπº¬á »α«úαá¼¼δ
-
- mov ah,4bh ;Σπ¡¬µ¿∩ exec
- mov al,0 ;óδí¿αáѼ "ºáúαπº¬π ¿ ºá»π߬"
- int 21h ;ºá»π߬áѼ ºáñáτπ
-
- ;---ó»«ß½ÑñßΓó¿¿, ó«ßßΓá¡áó½¿óáѼ αÑú¿ßΓαδ
-
- mov ax, _DATA ;ó«ßßΓá¡áó½¿óáѼ ds
- mov ds, ax
- mov ss, keep_ss ;ó«ßßΓá¡áó½¿óáѼ ss
- mov sp, keep_sp ;ó«ßßΓá¡áó½¿óáѼ sp
-
- @RestoreRegs
- ret
- SysCm ENDP
-
- UpStr PROC
- ;*
- ;* Convert string points SI to "upper case".
- ;*
- @SaveRegs si,di,es
- cld
- mov ax, ds
- mov es, ax
- mov di, si
-
- UpCycl:
- lodsb
- and al, al
- jz UpExit
- cmp al, 61h
- jb StChar
- cmp al, 7ah
- ja StChar
- sub al, 20h
-
- StChar:
- stosb
- jmp short UpCycl
-
- UpExit:
- @RestoreRegs
- ret
- UpStr ENDP
-
- END
-