home *** CD-ROM | disk | FTP | other *** search
- JMP START
-
- DB 0Dh,0Ah,'STUFFKB v 2.0 A Utility to Stuff the Keyboard with the Parameter String.',0Dh,0Ah
- DB 'Written by Ed Derzawiec',0Dh,0Ah
- DB '6 Sweet Fern Rd, Cape Elizabeth, ME 04107',0Dh,0Ah
- DB 'Declared Public Domain, 1989,1990'
- DB 1Ah ;Clean up a listing of this .COM file
-
-
- ParamLen EQU 080 ;PSP offset To Length Of Parameter String
- Params EQU 081 ;PSP offset to Parameters
-
- A_BS EQU 008 ;ASCII Code for BackSpace
- A_ESC EQU 01B ;Escape
- A_CR EQU 00D ;Carrage Return
- A_BELL EQU 007 ;Bell
-
- ;The Following are the control Words
- ;delimited by "~" characters on the command
- ;line to be translated into ASCII Code.
- ;This Table Format is "Word",0,Code,..,0
- ; "Word" is the Defined Control Word to Translate
- ; 0 Delimits the Control Word
- ; Code is the Assigned ASCII Code
- ; And a Final Null Identifies the End of the Table
- Controls:DB "CR",0,A_CR,"BS",0,A_BS,"ESC",0,A_ESC,0
-
- Head EQU 01A ;BIOS Pointer Location to Current Head and
- Tail EQU 01C ;Tail Of Circular Buffer
- KeyStart EQU 080 ;BIOS Pointer Location of Actual Start and
- KeyEnd EQU 082 ;End of the Circular Buffer
-
- Start: CMP b[ParamLen],2
- JL Exit ;Exit if No Parameters Passed
- CALL StuffKBRD
- Exit: SUB AH,AH
- INT 21h ;Exit Program
-
- Proc NEAR
- ; This routine will stuff the KeyBoard Buffer with the Parameter passed
- ; It won't work for extended characters (NON ASCII)
-
- StuffKBRD:PUSH ES
- MOV ES,AX,040 ;BIOS Data Segment resides in Page 40
- MOV SI,Params+1 ;Move Past FileName Delimiter (Space)
- MOV AX,ES:w[KeyStart];Get the Beginning Address of the Keyboard Buffer
- MOV DI,AX
- MOV ES:w[Head],AX ;Initialize Keyboard Buffer Pointer
- MOV AH,0 ;Null Out Scan Code (Not Normally Important)
- Stuff1: LODSb ;Get ASCII into AL
- CMP AL,A_CR ;End Stuff on Carrage Return in Parameter String
- JE Stuff9 ;Exit on end of string
- CMP AL,"~" ;Control Character Delimiter
- JNE Stuff2
- CALL ControlDecode
- Stuff2: STOSw ;Put into Keyboard Buffer (SCAN Code = 0)
- CMP DI,ES:w[KeyEnd] ;Don't Go Beyond Buffer's End
- JB Stuff1
- SUB DI,2 ;Buffer Can only Hold (Size-1) characters when full
- Stuff9: MOV ES:[Tail],DI ;Identify the end of the Keyboard Buffer
- POP ES
- RET
- ENDP
-
- Proc NEAR ;Compares the Delimited Control Command at [SI]
- ;With the Control String ([DI]) to find match
- ;and return ASCII equivalent in AL (incrementing SI)
- ControlDecode:
- PUSH ES ;Save The KeyBoard Data Segment
- PUSH DI ;And Current Pointer
- PUSH DS
- POP ES ;Move DS to ES
- CALL UPPER ;Convert Control Word in Params to UPPER CASE
- MOV DI,OFFSET(Controls)
- MOV AL,0
- MOV BX,SI
- Cntl1: MOV SI,BX
- MOV CX,80 ;80 Characters Max/String
- REPE
- CMPSb ;Increment SI,DI until a Mismatch is found
- CMP b[DI-1],AL ;Did the Match end in a proper control delimiter?
- JNE Cntl2 ;No, Get Try Next Control Word
- CMP b[SI-1],"~" ;Did the Match end in a proper control Delimiter?
- JNE Cntl2 ;No...
- MOV AL,b[DI] ;Load the Control Characters ASCII Code in AL
- JMP Cntl9
- Cntl2: REPNE
- SCASb ;Go to Next Control Word in Control Word List
- INC DI ;Skip ASCII Code of previous character
- CMP b[DI],AL ;Is this the End of the Control Word String
- JNE Cntl1 ;No, Continue search with Next Word
- MOV AL,A_Bell ;Stuff a beep on No Match Found...
- Cntl9: POP DI ;Restore the pointer to the Keyboard Buffer
- POP ES ;And Segment
- RET
- ENDP
-
- PROC NEAR ;Converts Control Word at SI to Upper Case
- Upper: PUSH SI ;Store the Pointer to the Start of the Word
- MOV AL,11011111xB
- Upper1: CMP b[SI],"~" ;Done?
- JE Upper9
- AND b[SI],AL ;Convert to upper CASE
- INC SI
- JMP Upper1
- Upper9: POP SI ;Restore Pointer
- RET
- ENDP
-