;	WinSTon

;	LINK An,#<displacement>

;	XNZVC
;	-----

PUBLIC _link

;-----------------------------------------------------------------------
;LINK An,#<displacement>
_link PROC NEAR
	mov		edx,DECODE_1[ecx]						;An 'edx'

	sub		DWORD PTR _Regs[REG_A7*4],SIZE_LONG		;SP-=4
	mov		ebp,_Regs[REG_A7*4]						;SP
	MASK_24BIT_ADDR(ebp)							;as 24-bit address in PC memory

	mov		ebx,[edx]								;An
	SWAP_ENDIAN_LONG_EBX
	mov		DWORD PTR _STRam[ebp],ebx				;(SP) = An

	mov		ebx,_Regs[REG_A7*4]
	mov		[edx],ebx								;An = SP

	mov		bx,IMM_WORD[esi]						;Immediate data (wrong endian)
	SWAP_ENDIAN_WORD_BX
	movsx	ebx,bx									;Sign extend offset
	add		esi,SIZE_WORD							;Increase program counter
	add		_Regs[REG_A7*4],ebx						;SP += d
	FRET
_link ENDP
