home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 September
/
Simtel20_Sept92.cdr
/
msdos
/
batutl
/
elf11.arc
/
ELF.A86
next >
Wrap
Text File
|
1988-08-07
|
4KB
|
108 lines
;************************************************************************
;* *
;* ELF.A86. This stupid program will set the specified error level*
;* for batch files. It has two modes of operation: If invoked by:*
;* ELF <CR> it will display: (Y/N)? on the screen & wait for one *
;* of these keys to be pressed. It will then exit with errorlevel *
;* 255 if N was pressed, or error level 0 if Y was pressed. With *
;* careful editing of prompts in a batch file, this can be used *
;* to make run-time operator decisions in batch files. *
;* The second invocation is: ELF XX <CR> Where XX is a two digit *
;* HEXIDECIMAL number. ELF will terminate with the specified *
;* error level. This can add error level processing to programs *
;* that do not support it by chaining to ELF upon termination. *
;* Remember that the batch file ERRORLEVEL command only accepts *
;* decimal radix arguments. Hex was used for ELF out of pure *
;* laziness on the part of the programmer! *
;* Written by: Mark D. Pickerill 9 Sept. 1988. The user bears *
;* all responsiblity for testing & use. ELF stands for (E)rror *
;* (L)evel (F)ile, although the name was inspired by Tolkien, *
;* more than anything else. COSMAC users take note! *
;* *
;************************************************************************
;
CR: EQU 0DH ; Carriage return
LF: EQU 0AH ; Line feed
EOF: EQU 1AH ; End of file
;
ORG 0100H ; Start of tpa
;
ELF: JMP START ; Jump past ego section
;
DB CR,LF,'ELF, Error Level File'
DB CR,LF,'By M.D.P. 9 Sept. 1988',EOF
;
START: PUSH CS ; Set data segment
POP DS ; It's set
PUSH DS ; Get this segment
POP ES ; And set es as well
MOV SI,0080H ; Point to parameter field in psp
MOV CL,[SI] ; Get parameter length
OR CL,CL ; Force flags
JZ NOPARMS ; Do y/n
MOV CH,00H ; Zero ch
LOOP1: INC SI ; Point to start of parameters
MOV AL,[SI] ; Get byte from parameter field
CMP AL,' ' ; Space?
LOOPZ LOOP1 ; Wait until you get a non-space char
JZ NOPARMS ; Do y/n
MOV AH,AL ; Get hex char
INC SI ; Next hex char
MOV AL,[SI] ; Get lsn
CALL GETHEX ; Convert to hex
XCHG AH,AL ; Store & retrieve msn
CALL GETHEX ; Convert
XCHG AH,AL ; Switch back
ADD AH,AH ; Compensate upper nybble
ADD AH,AH ;
ADD AH,AH ;
ADD AH,AH ; Ok, i`m tired of rotates!
OR AL,AH ; Ok we now have our number
MOV AH,4CH ; Mush dos terminate
INT 21H ; Terminate with specified error level
;
GETHEX: CMP AL,2FH ; <2f?
JL TERM ; Control, ignore
CMP AL,46H ; >46?
JG TERM ; Upper-case g or above, ignore
CMP AL,39H ; <39?
JLE NUMBER ; It's a number
CMP AL,41H ; <41?
JL TERM ; It's a punctuation, etc; ignore
LETTER: ADD AL,09H ; 9 makes the lsn=hex version of input
NUMBER: AND AL,0FH ; Strip msn, makes numbers hex & dumps
; Useless msn for letters
RET ; Near
;
TERM: MOV AX,4C01H ; Garbage parameters
INT 21H ;
;
MESSAGE:DB '(Y/N)?$' ; Question
;
NOPARMS:MOV AH,09H ; Print string function
LEA DX,MESSAGE ; Point
INT 21H ; Do it
NOPE: MOV AH,01H ; Console input
INT 21H ; Get char
AND AL,5FH ; Make upper case
CMP AL,'Y' ; Yes?
JZ YES ; Yes
CMP AL,'N' ; No?
JZ NO ; Yes
JMP NOPE ; Garbage, ignore
;
YES: CALL CRLF ;SEND CRLF
MOV AX,4C00H ; Error level 0 for yes
INT 21H ; We're history
NO: CALL CRLF ;SEND CRLF
MOV AX,4CFFH ; Error level ff for no
INT 21H ; We're history
CRLF: MOV AH,02H ;CONOUT FUNCTION
MOV DL,0DH ;SEND CR
INT 21H ;DO IT
MOV AH,02H ;CONOUT FUNCTION
MOV DL,0AH ;SEND LF
INT 21H ;DO IT
RET ;NEAR
END ;