.386p
	page 58,132
;=============================================================================
	title	A M I H I G H - HIGHSCAN for AMI BIOS systems
;=============================================================================
;==
;== (C) Copyright MICROSOFT Corp. 1993
;==
;==	Title:	EMM386.EXE - MICROSOFT Expanded Memory Manager 386 Driver
;==
;==	Module: AMIHigh - Specail case HIGHSCAN code for AMI BIOS systems
;==
;==	Version: 1.00
;==
;==	Date:	12-Sep-1993
;==
;=============================================================================
;==
;==	Change Log:
;==
;==	DATE	 REVISION	Description
;==	-------- --------	--------------------------------------------
;==	09/12/93 0.00		Original
;==
;==
;=============================================================================

;=============================================================================
;==	E X T E R N A L  D E C L A R A T I O N S
;=============================================================================
LAST	segment

	extrn	HighSet:word

LAST	ends

;=============================================================================
;==	L O C A L   C O N S T A N T S
;=============================================================================

	include vdmseg.inc
	include emm386.inc
	include emmdata.inc

;=============================================================================
;==	C O D E  S E G M E N T
;=============================================================================
LAST	segment
	assume	cs:LAST,ds:_DATA,gs:R_CODE

;=============================================================================
;==	L O C A	L   D A T A
;=============================================================================

sAMI	db	'AMERICAN MEGATRENDS INC'
endsAMI label	byte

sDATE_LEN equ	8			; each date string must be 8 chars long

sDATE	db	'07/07/91'		; ROM dates to special case
	db	'04/25/91'
	db	0			; end of date list

; Special case handling of AMI BIOS versions:
;
; 07/07/91 - disable HIGHSCAN; there is live ROM code in the F000-F7FF range
;	     that is jumped to from the upper 32k.  In particular the Int 08h
;	     handler jumps to a low ROM location.
;
; 04/25/91 - same problem as 07/07/91 version, different low 32k location.


;***************************************************************************
;
; AMI_HighScan - Special case AMI BIOS HIGHSCAN routines
;
; Entry:
;	Nothing.
;
; Exit:
;	CY clear is AMI BIOS that this routine has handled
;	CY set	 if normal HIGHSCAN checking should be performed.
;
; Uses:
;	Flags.

	public	AMI_HighScan

AMI_HighScan	PROC  near

	push	ax		; Save registers
	push	bx
	push	cx
	push	dx
	push	si
	push	di
	push	ds
	push	es

	push	cs
	pop	ds
	assume	ds:LAST

; Address the system BIOS

	mov	ax,0f000h	; Address the System BIOS
	mov	es,ax		; ... via ES
	assume	es:nothing	; Tell the assembler about it

; Look for AMI identifier

	cld
	xor	di, di			; start searching @ F000:0000

scan_ROM:
	mov	si, offset LAST:sAMI	; looking for this string

scan_next:
	mov	ah, es:[di]		; next char from ROM
	cmp	ah, 'a'
	jb	no_uc
	cmp	ah, 'z'
	ja	no_uc
	and	ah, NOT 20h		; force uppercase for comparison
no_uc:
	inc	di			; forever onward...
	cmp	di, 100h		; must find before this location
	jae	not_AMI

	lodsb				; first/next char to match

	cmp	ah, al			; match?
	jne	scan_ROM		;   no, go restart scan

	cmp	si, offset LAST:endsAMI ; did entire string match?
	jae	is_AMI

	jmp	short scan_next 	; go try to match next char

	; Found the AMI id string.  Now check if this is a special cased
	; BIOS version.

is_AMI:
	xor	bx, bx

scan_date:
	mov	si, offset LAST:sDATE	; si -> start of date strings
	add	si, bx			; si -> next date string to check
	cmp	byte ptr [si], 0	; checked all date strings?
	je	not_special		;   yes, not a special cased BIOS

	mov	di, 0FFF5h		; location of date string in ROM
	mov	cx, sDATE_LEN
	repe	cmpsb			; is this the one?
	je	special_AMI		;   yes, go do special case code

	add	bx, sDATE_LEN		; bump to next date string
	jmp	short scan_date

	; Found an AMI BIOS with selected date.  Currently the only special
	; case handling we do is to disable HIGHSCAN on this machine.

special_AMI:
	clc				; Indicate AMI BIOS handled
	jmp	short ami_exit

	; Either this is not an AMI BIOS or it's not a special cased version.
	; Set the CY flag telling the caller to go ahead with it's normal
	; HIGHSCAN processing.

not_AMI:
not_special:
					; Indicate not an AMI BIOS or not
	stc				; a special cased version.

ami_exit:
	pop	es			; Restore registers
	pop	ds
	assume	ds:_DATA
	pop	di
	pop	si
	pop	dx
	pop	cx
	pop	bx
	pop	ax
	assume	es:nothing

	ret

AMI_HighScan	endp


LAST	ENDS
	END
