
; Detect CPU type, abort if not 80386

; if os33 defined, check operating system version, abort if not 3.3

	.8086
sychk	proc	near

	pushf
	mov	ax,4000h
	push	ax
	popf
	pushf
	pop	ax
	popf
	and	ah,0c0h
	js	xcpu		;80186 or earlier
	jz	xcpu		;80286
				;80386
    ifdef <os33>
	mov	ax,3000h
	int	21h
	cmp	ax,1e03h
	jnz	xdos		;not version 3.3
    endif
	ret

xcpu:	mov	si,os xcpum
    ifdef <os33>
	jmp	xerr
xdos:	mov	si,os xdosm
    endif
xerr:	call	errout
	mov	ax,4cffh
	int	21h

errout:	push	si		;write fn: message on stderr
	mov	si,os fnm
	call	wserr		;display filename
	pop	si		;display error message

wserr:	mov	ah,40h		;write file
	mov	bx,2		;stderr handle
	mov	ch,bh		;zero
	mov	cl,[si]		;length
	mov	dx,si
	inc	dx		;address message
	int	21h
	ret

% fnm:	dbl	<13,10,'&@filename: '>
xcpum:	dbl	<'requires 80386 cpu',13,10>
    ifdef <os33>
xdosm:	dbl	<'requires msdos 3.3',13,10>
    endif

sychk	endp
