;	WinSTon

;	CHK <ea>,Dn

;	XNZVC
;	-*UUU

PUBLIC _chk_ea_dn_word

;-----------------------------------------------------------------------
;CHK.W <ea>,Dn
_chk_ea_dn_word PROC NEAR
	EFFADDR_READ									;Read <ea>
	mov		edx,DECODE_2[ecx]						;DReg
	mov		dx,WORD PTR [edx]

	cmp		dx,0									;Dn < 0
	jl		out_bounds_low
	cmp		dx,bx									;Dn > <ea>
	jg		out_bounds_high
	FRET

out_bounds_low:
	or		al,EMU_N								;Dn<0, set N
	jmp		out_bounds

out_bounds_high:
	and		eax,EMU_CLEAR_N							;Dn><ea>, clear N

out_bounds:
	mov		[_ExceptionVector],EXCEPTION_CHK
	call	asm_exception							;Cause trap
	FRET
_chk_ea_dn_word ENDP
