include	clib.inc
include	string.inc

	public	isexec

_TEXT	SEGMENT

isexec	PROC	DIST	; (char *filename);
	push	dx
	push	ax	; Test if <ext> == bat | com | exe
	mov	al,'.'
	push	ax
	call	strrchr
	jz	isexec_NOT
	mov	es,dx
	inc	ax
	mov	bx,ax
	mov	dx,'  '
	mov	ax,es:[bx]
	mov	bx,es:[bx+2]
	or	ax,dx
	or	bx,dx
	cmp	ax,'ab'
	je	isexec_BAT
	cmp	ax,'oc'
	je	isexec_COM
	cmp	ax,'xe'
	je	isexec_EXE
    isexec_NOT:
	xor	ax,ax
    isexec_END:
	ret
    isexec_EXE:
	cmp	bx,' e'
	jne	isexec_NOT
	mov	ax,3	; 3 = EXE
	jmp	isexec_END
    isexec_COM:
	cmp	bx,' m'
	jne	isexec_NOT
	mov	ax,2	; 2 = COM
	jmp	isexec_END
    isexec_BAT:
	cmp	bx,' t'
	jne	isexec_NOT
	mov	ax,1	; 1 = BAT
	jmp	isexec_END
isexec	ENDP

_TEXT	ENDS

	END
