INCLUDE		chip.h

DECLARE_INDIR1_ICEMode EQU 1
include 	sn8cc_macros.asm
INCLUDESTD	MACRO1.H

; 2006.12.29 sol add if condition 

IF SW_1819A==1
include 1819AEV.h

ELSEIF SW_1829==1
include 1829EV.h

ELSEIF SO_1907==1
include 1907EV.h

ELSEIF SO_1917==1
include 1917EV.h

ELSEIF SO_1927==1
include 1927EV.h

ELSEIF SO_1927A==1
include 1927AEV.h

ELSEIF SO_1937==1
include 1937EV.h

ELSEIF SW_1919==1
include 1919EV.h

ELSEIF SW_1989==1
include 1989EV.h

ELSEIF SW_1929==1
include 1929EV.h

ELSE
include 1909EV.h
ENDIF
; end if 


IF ICE_Mode==1
	extern code @@delayTime;
	IF SO_1937==1
		extern code Parallel_Write;  //Sol add this for support  xmov 2007.01.03
		extern code Parallel_Read;
	ELSE
		extern code SIO;  //Sol add this for support  xmov 2007.01.03
	ENDIF
ENDIF

PUBLIC __INDIR1_ICEMode

_x_c__INDIR1_ICEMode@RTSegment segment code INBANK
__INDIR1_ICEMode:
	;check bank, if is not 0, it does not point to SFR
	B0MOV A, Y
	CMPRS A, #0
	JMP _INDIR_ATYZ	
/*********************************************************/
;judge rang is between 0x90 ~ 0x9f?	
	B0MOV A, Z
	SUB A,#0x90
	B0BTS1 FC
	JMP _INDIR_ATYZ

  B0MOV A, Z
	CMPRS A, #0xa0
	B0BTS0 FC
	JMP _INDIR_ATYZ

/********************************************************/ 

  b0mov	a,Z	; get register address value
	b0mov	R_Temp0,a	;

IF RBANK != 0		
	B0mov	a,RBANK		; 
	B0mov	R_Temp3,a	; Save RBANK data to R_Temp3			
	b0mov	RBANK,#00H		; Change to RBANK0
ENDIF
	
	b0bset	R_Temp0.7	; use bit7 mark to read mode flag.
	
	IF SO_1937==1
		call	Parallel_Write	; send read address to emulation board
		;call	@@delayTime	; waiting for emulation board process command & address
		call	Parallel_Read	; received emulation board data		
	ELSE
		call	SIO			; send read address to emulation board
		call	@@delayTime	; waiting for emulation board process command & address
		call	SIO			; received emulation board data
	ENDIF
	
	b0mov	R_Temp2,a

IF RBANK != 0		
	b0mov	a,R_Temp3	; 
	b0mov	RBANK,a		; Re-Load RBANK data from R_Temp3
ENDIF
	
	b0mov	a,R_Temp2

/********************************************************/ 
JMP _RET

_INDIR_ATYZ:	
	B0MOV A, @YZ
_RET:	
	RET