;	WinSTon

;	MULU <ea>,Dn

;	XNZVC
;	-****

PUBLIC _mulu_ea_dn_word

;-----------------------------------------------------------------------
;MULU.W <ea>,Dn
_mulu_ea_dn_word PROC NEAR
	EFFADDR_READ									;Read <ea>

	push	eax										;Keep our emulation ccodes
	mov		ebp,DECODE_2[ecx]						;DReg
	mov		ax,WORD PTR [ebp]						;Destination ('Dn' so correct endian)
		
	;bx * ax
	and		eax,00000ffffh
	and		ebx,00000ffffh
	xor		edx,edx
	mul		ebx										;edx:eax result, sets CV if overflow into edx
	mov		[ebp],eax								;And store

	pushf
	pop		cx										;Contains CV
	or		eax,eax									;Set NZ
	pushf
	pop		ax

	;Merge CV with eax
	and		eax,NOT (PC_CARRY+PC_OVERFLOW)
	and		ecx,PC_CARRY+PC_OVERFLOW
	or		eax,ecx
	push	ax
	popf

	pop		eax										;Restore emulation ccodes
	SET_NZVC
_mulu_ea_dn_word ENDP
