;	WinSTon

;	STOP

;	XNZVC
;	*****

PUBLIC _stop

;-----------------------------------------------------------------------
;STOP
_stop PROC NEAR
	mov		bx,IMM_WORD[esi]						;Immediate data (wrong endian)
	add		esi,SIZE_WORD							;Increase program counter
	SWAP_ENDIAN_WORD_BX

	;Is CPU already stopped?
	cmp		[_CPUStopped],TRUE
	je		already_stopped

	;Set flag to say CPU has stopped
	mov		[_CPUStopped],TRUE
	;And set SR to immediate data
	mov		ax,bx									;Get new SR
	call	asm_check_usersuper_swap				;Write 'eax' to SR, swap modes and return ccodes in 'eax'

already_stopped:
	;Force emulator to stick on STOP instruction(length is 4-bytes)
	sub		esi,4									;sizeof(STOP) instruction(op-code+imm)
	FRET
_stop ENDP
