.nlist
;****************************************************************************
;
; Include This File To Define The AT89LP428/828 SFRs
;
;	!!! NOTE !!!
;		Only SFR Registers And
;		Bit Addressable Register Bits Are Defined
;
;****************************************************************************
;
	; Set UPPER_CASE_SFR Non Zero To Define Upper Case SFRs
	; Set LOWER_CASE_SFR Non Zero To Define Lower Case SFRs
	; Else Both Upper And Lower Case SFRs Will Be Defined

	.ifeq	UPPER_CASE_SFR + LOWER_CASE_SFR
		UPPER_CASE_SFR = 1
		LOWER_CASE_SFR = 1
	.endif

;
;****************************************************************************
;
	; Macro To Define Bit Addressable SFRs By Bit Number
        ; Creates Symbols str.0 = addr+0, str.1 = addr+1, ... , str.7 = addr+7
	.macro	.sfr.n	addr, str
	  .ifnb	str
	    .irpc c ^/01234567/
	str'.'c =: addr + c
	    .endm
	  .endif
	.endm

;
;****************************************************************************
;
	; Macro To Define SFR Bit Names
	; Creates Symbols str0 = addr+0, str1 = addr+1, ..., str7 = addr+7
	.macro	.sfr.b	addr, str0, str1, str2, str3, str4, str5, str6, str7
	  sfr$n =: 0
	  .irp	str, str0, str1, str2, str3, str4, str5, str6, str7
	    .ifnb str
	str =: addr + sfr$n
	    .endif
	    sfr$n = sfr$n + 1
	  .endm
	.endm

;
;****************************************************************************
;
	; Macro To Define SFRs By Register Names
	; Creates Symbols str0 = addr+0, str1 = addr+1, ..., str7 = addr+7
	.macro	.sfr.r	addr, str0, str1, str2, str3, str4, str5, str6, str7
	  sfr$n =: 0
	  .ifndef sfr$'addr
	    sfr$'addr =: 0
	  .endif
	  .irp	str, str0, str1, str2, str3, str4, str5, str6, str7
	    .ifnb str
	str =: addr + sfr$n
	sfr$'addr = sfr$'addr | (1 << sfr$n)
	    .endif
	    sfr$n = sfr$n + 1
	  .endm
	.endm

;
;****************************************************************************

.ifne	UPPER_CASE_SFR
	.list	(!,src)
;	AT89LP428/828 Upper Case SFRs         Defined
	.nlist

.sfr.n	0x80,	P0
.sfr.r	0x80,	P0,	SP,	DP0L,	DP0H,	DP1L,	D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xC0	P4,	,	P1M0,	P1M1,	P2M0,	P2M1,	P3M0,	P3M1

.sfr.n	0xC8	T2CON
.sfr.b	0xC8	CPRL2,	CT2,	TR2,	EXEN2,	TCLK,	RCLK,	EXF2,	TF2
.sfr.r	0xC8	T2CON,	T2MOD,	RCAP2L,	RCAP2H,	TL2,	TH2,	,

.sfr.n	0xD0,	PSW
.sfr.b	0xD0,	P,	,	OV,	RS0,	RS1,	F0,	AC,	CY
.sfr.r	0xD0,	PSW,	T2CCA,	T2CCL,	T2CCH,	T2CCC,	T2CCF,	,

.sfr.n	0xD8,
.sfr.r	0xD8,	,	,	,	,	,	,	,

.sfr.n	0xE0,	A
.sfr.n	0xE0,	ACC
.sfr.r	0xE0,	ACC,	,	,	,	,	,	,

.sfr.n	0xE8,	SPSR
.sfr.b	0xE8,	ENH,	DISSO,	SSIG,	,	TXE,	MODF,	WCOL,	SPIF
.sfr.r	0xE8,	SPSR,	SPCR,	SPDR,	,	,	,	,

.sfr.n	0xF0,	B
.sfr.r	0xF0,	B,	,	,	,	,	,	,

.sfr.n	0xF8,
.sfr.r	0xF8,	,	,	,	,	,	,	,

;
;	The macro .sfr.r also creates the definition sfr$'addr
;	that has a bit set for each SFR that is defined.  After
;	processing the complete SFR table there will be 16
;	definitions:
;
;	sfr$0x80	sfr$0x88	sfr$0x90	sfr$0x98
;	sfr$0xA0	sfr$0xA8	sfr$0xB0	sfr$0xB8
;	sfr$0xC0	sfr$0xC8	sfr$0xD0	sfr$0xD8
;	sfr$0xE0	sfr$0xE8	sfr$0xF0	sfr$0xF8
;

.endif

.ifne	LOWER_CASE_SFR
	.list	(!,src)
;	AT89LP428/828 Lower Case SFRs         Defined
	.nlist

.sfr.n	0x80,	p0
.sfr.r	0x80,	p0,	sp,	dp0l,	dp0h,	dp1l,	dp1h,	page,	pcon
.sfr.r	0x80,	,	,	dpl,	dph	,	,	,
.sfr.r	0x80,	,	,	dptrl,	dptrh	,	,	,

.sfr.n	0x88,	tcon
.sfr.b	0x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,	th2,	,

.sfr.n	0xd0,	psw
.sfr.b	0xd0,	p,	,	ov,	rs0,	rs1,	f0,	ac,	cy
.sfr.r	0xd0,	psw,	t2cca,	t2ccl,	t2cch,	t2ccc,	t2ccf,	,

.sfr.n	0xd8,
.sfr.r	0xd8,	,	,	,	,	,	,	,

.sfr.n	0xe0,	a
.sfr.n	0xe0,	acc
.sfr.r	0xe0,	acc,	,	,	,	,	,	,

.sfr.n	0xe8,	spsr
.sfr.b	0xe8,	enh,	disso,	ssig,	,	txe,	modf,	wcol,	spif
.sfr.r	0xe8,	spsr,	spcr,	spdr,	,	,	,	,

.sfr.n	0xf0,	b
.sfr.r	0xf0,	b,	,	,	,	,	,	,

.sfr.n	0xf8,
.sfr.r	0xf8,	,	,	,	,	,	,	,

;
;	The macro .sfr.r also creates the definition sfr$'addr
;	that has a bit set for each SFR that is defined.  After
;	processing the complete SFR table there will be 16
;	definitions:
;
;	sfr$0x80	sfr$0x88	sfr$0x90	sfr$0x98
;	sfr$0xa0	sfr$0xa8	sfr$0xb0	sfr$0xb8
;	sfr$0xc0	sfr$0xc8	sfr$0xd0	sfr$0xd8
;	sfr$0xe0	sfr$0xe8	sfr$0xf0	sfr$0xf8
;

.endif

