include	clib.inc

	extrn	errnotable:byte
	extrn	doserrtable:byte

	public	@dosmaper

_TEXT	SEGMENT

@dosmaper PROC
	push	ds
	push	dx
	push	cx
	push	ss
	pop	ds
	mov	dx,ax
	mov	doserrno,ax
	xor	cx,cx
	jmp	dosmaper_loop
    dosmaper_next:
	mov	bx,cx
	cmp	dl,[bx+doserrtable]
	jnz	dosmaper_01
	xor	ax,ax
	mov	al,[bx+errnotable]
	mov	errno,ax
	jmp	dosmaper_end
    dosmaper_01:
	inc	cx
    dosmaper_loop:
	cmp	cx,45
	jl	dosmaper_next
	cmp	dx,19
	jb	dosmaper_37
	cmp	dx,36
	ja	dosmaper_37
	mov	errno,13
	jmp	dosmaper_end
    dosmaper_37:
	cmp	dx,188
	jb	dosmaper_22
	cmp	dx,202
	ja	dosmaper_22
	mov	errno,8
	jmp	dosmaper_end
    dosmaper_22:
	mov	errno,22
    dosmaper_end:
	xor	ax,ax
	mov	ax,doserrno
	pop	cx
	pop	dx
	pop	ds
	ret
@dosmaper ENDP

_TEXT	ENDS

	END
