;	WinSTon

;	RTE

;	XNZVC
;	-----

PUBLIC _rte

;-----------------------------------------------------------------------
;RTE
_rte PROC NEAR
	mov		ebp,_Regs[REG_A7*4]						;SP
	MASK_24BIT_ADDR(ebp)							;as 24-bit address in PC memory

	mov		ax,WORD PTR _STRam[ebp]					;SR(wrong endian)
	SWAP_ENDIAN_WORD_AX								;Write later...

	mov		esi,DWORD PTR _STRam[ebp+SIZE_WORD]		;PC(wrong endian)
	bswap	esi
	mov		[_PC],esi								;Retain top byte of program counter
	MASK_24BIT_ADDR(esi)							;New program counter		
	add		esi,STRAM_OFFSET						;As PC address space
	add		DWORD PTR _Regs[REG_A7*4],SIZE_WORD+SIZE_LONG		;SP+=2+4

	call	asm_check_usersuper_swap				;Write 'eax' to SR, swap modes and return ccodes in 'eax'
	FRET
_rte ENDP
