; TASKING TriCore C compiler v1.5r1 Build 322 SN 00090364
; options: -e -A1 -g -O0 -Id:\ctri\include -s -N8 -zTC112_COR1 -zTC112_COR4
;          -zTC112_COR10 -zTC112_COR13 -zTC112_COR14 -zTC112_COR16 -zTC112_COR17
	.name	"flash_test"
	.symb	TOOL, "TASKING TriCore C compiler v1.5", 1
	.symb	TYPE, 256, "bit", 'g', 0, 1
	.symb	FILE, "flash_test.c"
; file "flash_test.c":
;    1 |// Flash_test.c
;    2 |
;    3 |#define	SETUP_ADDR		0x1554
;    4 |#define UNLOCK_ADDR		0xAA8
;    5 |/* flash commands */
;    6 |#define	AMDSETUP     	0x00AA00AA
;    7 |#define	AMDUNLOCK     	0x00550055
;    8 |#define	AMDREAD_ID    	0x00900090
;    9 |#define	AMDPROGRAM    	0x00A000A0
;   10 |#define	AMDCHIP_ERASE1	0x00800080
;   11 |#define	AMDCHIP_ERASE2	0x00100010
;   12 |#define	AMDSECTOR_ERASE	0x00300030
;   13 |#define	AMDRESET       	0x00F000F0
;   14 |
;   15 |#define	INTELREAD_ID   	0x00900090
;   16 |#define	INTELREAD_ARRAY	0x00FF00FF
;   17 |#define	INTELREAD_STAT 	0x00700070
;   18 |#define	INTELCLR_STAT 	0x00500050
;   19 |#define	INTELBLK_ERASE 	0x00200020
;   20 |#define	INTELRESUME    	0x00D000D0
;   21 |#define	INTELSUSPEND   	0x00B000B0
;   22 |#define	INTELPROG_STD   0x00400040
;   23 |#define	INTELPROG_ALT   0x00100010
;   24 |#define	INTELSET_CFG1   0x00600060
;   25 |#define	INTELSET_CFG2   0x00030003
;   26 |
;   27 |/* bits for Polling (end of operation) */
;   28 |#define DQ7				0x00800080
;   29 |#define DQ5  			0x00200020
;   30 |
;   31 |#define	STAT_WSMS    	0x00800080
;   32 |#define	STAT_ESS     	0x00400040
;   33 |#define	STAT_ES      	0x00200020
;   34 |#define	STAT_PS      	0x00100010
;   35 |#define	STAT_VPPS    	0x00080008
;   36 |#define	STAT_PSS     	0x00040004
;   37 |#define	STAT_DPS     	0x00020002
;   38 |#define	STAT_R       	0x00010001
;   39 |
;   40 |/* result of command */
;   41 |#define SUCCESS			0x0
;   42 |#define FAILURE   		0x1
;   43 |#define WRITE_ERROR		0x3
;   44 |#define DATA_ERROR		0x4
;   45 |
;   46 |#define MANU_ID_AMD       0x0001
;   47 |#define MANU_ID_TOSHIBA   0x0098
;   48 |#define MANU_ID_INTEL     0x0089
;   49 |#define MANU_ID_FUJITSU   0x0004
;   50 |
;   51 |#define	AM29LV200TB_ID	  0x223B
;   52 |#define	AM29LV200BB_ID	  0x22BF
;   53 |#define	AM29LV400TB_ID	  0x22B9
;   54 |#define	AM29LV400BB_ID	  0x22BA
;   55 |#define	AM29LV800TB_ID	  0x22DA
;   56 |#define	AM29LV800BB_ID	  0x225B
;   57 |#define	AM29LV160TB_ID	  0x22C4
;   58 |#define	AM29LV160BB_ID	  0x2249
;   59 |#define	AM29BL162C_ID	  0x2203
;   60 |#define	AM29BL802C_ID	  0x2281
;   61 |
;   62 |#define	DT28F800F3T_ID	  0x88F1
;   63 |#define	DT28F800F3B_ID	  0x88F2
;   64 |#define	DT28F160F3T_ID	  0x88F3
;   65 |#define	DT28F160F3B_ID	  0x88F4
;   66 |
;   67 |#define	TC58FVT400FT_ID	  0x00CD
;   68 |#define	TC58FVB400FT_ID	  0x004C
;   69 |#define	TC58FVT800FT_ID	  0x004F
;   70 |#define	TC58FVB800FT_ID	  0x00CE
;   71 |#define	TC58FVT160FT_ID	  0x00C2
;   72 |#define	TC58FVB160FT_ID	  0x0043
;   73 |
;   74 |#define	MBM29DL323TE_ID	  0x2250 //AMD compatible
;   75 |
;   76 |#define	KB_512_SIZE		  0x00080000
;   77 |#define	MB_1_SIZE		  0x00100000
;   78 |#define	MB_2_SIZE		  0x00200000
;   79 |#define	MB_4_SIZE		  0x00400000
;   80 |#define	MB_8_SIZE		  0x00800000
;   81 |
;   82 |#include "stdio.h"
	.symb	FILE, "d:\\ctri\\include\\stdio.h"
	.symb	FILE, "d:\\ctri\\include\\stdarg.h"
	.symb	ENDF
	.symb	TYPE, 258, 'P', #2
	.symb	TYPE, 259, "_iobuf", 'S', 24,\
		 "_ptr", #258, 0,\
		 "_base", #258, 4,\
		 "_cnt", #16, 8,\
		 "_bufsiz", #16, 12,\
		 "_flag", #5, 16,\
		 "_file", #2, 18,\
		 "_wcnt", #16, 20
	.symb	TYPE, 260, "FILE", 'T', #259
	.symb	TYPE, 261, "va_list", 'T', #258
	.symb	TYPE, 262, "size_t", 'T', #18
	.symb	TYPE, 263, "fpos_t", 'T', #7
	.symb	TYPE, 264, "off_t", 'T', #6
	.symb	ENDF
;   83 |
;   84 |//Flashtest.c
;   85 |
;   86 |unsigned int Read_ID( unsigned int uiFlashBase );
;   87 |unsigned int Chip_Erase(unsigned int uiID, unsigned int uiFlashBase);
;   88 |unsigned int Program_Word(unsigned int uiID, unsigned int uiAddress, unsigned int uiValue, unsigned int uiFlashBase );
;   89 |unsigned int Intel_Flash_ID( unsigned int uiFlashBase );
;   90 |unsigned int Intel_Chip_Erase(unsigned int uiID, unsigned int uiFlashBase);
;   91 |unsigned int Intel_Program_Word( unsigned int uiAddress, unsigned int uiValue );
;   92 |unsigned int AMD_Flash_ID( unsigned int uiFlashBase );
;   93 |unsigned int AMD_Data_Polling( unsigned int uiAddress, unsigned int uiValue );
;   94 |unsigned int AMD_Chip_Erase( unsigned int uiFlashBase );
;   95 |unsigned int AMD_Sector_Erase( unsigned int uiAddress, unsigned int uiFlashBase );
;   96 |unsigned int AMD_Program_Word( unsigned int uiAddress, unsigned int uiValue, unsigned int uiFlashBase );
;   97 |unsigned char FLASH_TEST_BANK1 (void);
;   98 |unsigned char FLASH_TEST_BANK2 (void);
;   99 |
;  100 |
;  101 |// Es wird von Code zwischen A0000000-A000FFFF und
;  102 |// Data zwischen A0010000-A001FFFF ausgegangen
;  103 |unsigned char FLASH_TEST_BANK1 (void)
;  104 |{
	.sdecl	"code.flash_test",CODE
	.sect	"code.flash_test"
	.align	4
	.symb	LINE, 104
	.symb	TYPE, 265, 'X', 8, #3, 26, 0
	.symb	GFUN, "FLASH_TEST_BANK1", FLASH_TEST_BANK1, #265, 0, 48, 0
	.symb	ALAB, FLASH_TEST_BANK1, #265
FLASH_TEST_BANK1:
	.symb	SOFF, 48
	.symb	IDEN, "ucErrorFlag", -36, #3, 131, 0x5
	.symb	IDEN, "uiFlashID", -32, #18, 131, 0x5
	.symb	IDEN, "uiFlashSize", -28, #18, 131, 0x5
	.symb	IDEN, "uiBaseFlashAddrAtCS0", -24, #18, 131, 0x5
	.symb	IDEN, "uiEndFlashTestCS0", -20, #18, 131, 0x5
	.symb	IDEN, "uiHilf", -16, #18, 131, 0x5
	.symb	IDEN, "uiCnt", -12, #18, 131, 0x5
	.symb	TYPE, 267, 'P', #18
	.symb	IDEN, "puiDest", -8, #267, 131, 0x5
	nop
	sub16.a	sp,#48
;  105 |
;  106 |unsigned char ucErrorFlag;
;  107 |unsigned int uiFlashID;
;  108 |unsigned int uiFlashSize;
;  109 |unsigned int uiBaseFlashAddrAtCS0;
;  110 |unsigned int uiEndFlashTestCS0;
;  111 |unsigned int uiHilf;
;  112 |unsigned int uiCnt;
;  113 |unsigned int *puiDest;
;  114 |
;  115 |ucErrorFlag = 0;
	.symb	LINE, 115
	mov16	d15,#0				; ucErrorFlag
	st16.b	[sp]12,d15			; ucErrorFlag
;  116 |uiFlashID=0;
	.symb	LINE, 116
	mov16	d15,#0				; uiFlashID
	st16.w	[sp]16,d15			; uiFlashID
;  117 |uiFlashSize = 0;
	.symb	LINE, 117
	mov16	d15,#0				; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  118 |uiBaseFlashAddrAtCS0 = 0xB0000000;
	.symb	LINE, 118
	movh	d15,#0xb000			; uiBaseFlashAddrAtCS0
	st16.w	[sp]24,d15			; uiBaseFlashAddrAtCS0
;  119 |uiEndFlashTestCS0 = 0;
	.symb	LINE, 119
	mov16	d15,#0				; uiEndFlashTestCS0
	st16.w	[sp]28,d15			; uiEndFlashTestCS0
;  120 |uiHilf = 0;
	.symb	LINE, 120
	mov16	d15,#0				; uiHilf
	st16.w	[sp]32,d15			; uiHilf
;  121 |
;  122 |
;  123 |printf("Testing FLASH at /CS0...\n");
	.symb	LINE, 123
	movh.a	a4,#@his(_17)
	lea	a4,[a4]@los(_17)
	callg	printf
;  124 |// Ist der Flash Hersteller der Testsoftware bekannt?
;  125 |uiFlashID = Read_ID( uiBaseFlashAddrAtCS0 );
	.symb	LINE, 125
	ld.w	d4,[sp]24			; uiBaseFlashAddrAtCS0
	callg	Read_ID
	st.w	[sp]16,d2			; uiFlashID
;  126 |if (((uiFlashID>>16) != MANU_ID_AMD) &&
;  127 |    ((uiFlashID>>16) != MANU_ID_TOSHIBA) &&
;  128 |	((uiFlashID>>16) != MANU_ID_FUJITSU) &&
;  129 |    ((uiFlashID>>16) != MANU_ID_INTEL))
	.symb	LINE, 129
	ld16.w	d15,[sp]16			; uiFlashID
	sh	d15,d15,#-16
	jeq	d15,#1,_55
	ld16.w	d15,[sp]16			; uiFlashID
	sh	d15,d15,#-16
	ne	d15,d15,#152
	jeq	d15,#0,_55
	ld16.w	d15,[sp]16			; uiFlashID
	sh	d15,d15,#-16
	jeq	d15,#4,_55
	ld16.w	d15,[sp]16			; uiFlashID
	sh	d15,d15,#-16
	ne	d15,d15,#137
	jeq	d15,#0,_55
;  130 |    {
;  131 |    printf("	Unknown Manufacturer ID [%X]\n", uiFlashID>>16);
	.symb	LINE, 131
	movh.a	a4,#@his(_18)
	lea	a4,[a4]@los(_18)
	ld16.w	d15,[sp]16			; uiFlashID
	sh	d15,d15,#-16
	st16.w	[sp],d15
	callg	printf
;  132 |	ucErrorFlag=1;
	.symb	LINE, 132
	mov16	d15,#1				; ucErrorFlag
	st16.b	[sp]12,d15			; ucErrorFlag
;  133 |	return(ucErrorFlag);
	.symb	LINE, 133
	ld.bu	d2,[sp]12			; ucErrorFlag
	ret16
;  134 |    }
	.symb	LINE, 134
_55:
;  135 |
;  136 |// Ist der Flash-Typ bekannt?
;  137 |switch (uiFlashID & 0xFFFF)
	.symb	LINE, 137
	nop
	ld16.w	d15,[sp]16			; uiFlashID
	mov.u	d7,#65535			; 65535
	and16	d15,d7
	addi	d15,d15,#-72
	jeq	d15,#-5,_70			; case 67
	jeq	d15,#4,_59			; case 76
	jeq	d15,#7,_62			; case 79
	addi	d15,d15,#-127
	jeq	d15,#-5,_69			; case 194
	jeq	d15,#6,_58			; case 205
	jeq	d15,#7,_63			; case 206
	addi	d15,d15,#-8508
	jeq	d15,#0,_73			; case 8707
	addi	d15,d15,#-63
	jeq	d15,#-7,_56			; case 8763
	jeq	d15,#7,_72			; case 8777
	addi	d15,d15,#-18
	jeq	d15,#-4,_76			; case 8784
	jeq	d15,#7,_65			; case 8795
	addi	d15,d15,#-45
	jeq	d15,#0,_66			; case 8833
	addi	d15,d15,#-62
	jeq	d15,#-6,_60			; case 8889
	jeq	d15,#-5,_61			; case 8890
	jeq	d15,#0,_57			; case 8895
	jeq	d15,#5,_71			; case 8900
	addi	d15,d15,#-27
	jeq	d15,#0,_64			; case 8922
	addi	d15,d15,#-26138
	jeq	d15,#-3,_67			; case 35057
	jeq	d15,#-2,_68			; case 35058
	jeq	d15,#-1,_75			; case 35059
	jeq	d15,#0,_74			; case 35060
	j	_77				; default
;  138 |      {
;  139 |      case AM29LV200TB_ID:
	.symb	LINE, 139
_56:
;  140 |         printf("	Flash name = AM29LV200TB\n");
	.symb	LINE, 140
	movh.a	a4,#@his(_19)
	lea	a4,[a4]@los(_19)
	callg	printf
;  141 |         uiFlashSize = KB_512_SIZE;
	.symb	LINE, 141
	movh	d15,#0x8			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  142 |         break;
	.symb	LINE, 142
	j	_98
;  143 |      case AM29LV200BB_ID:
	.symb	LINE, 143
_57:
;  144 |         printf("	Flash = AM29LV200BB\n");
	.symb	LINE, 144
	movh.a	a4,#@his(_20)
	lea	a4,[a4]@los(_20)
	callg	printf
;  145 |         uiFlashSize = KB_512_SIZE;
	.symb	LINE, 145
	movh	d15,#0x8			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  146 |         break;
	.symb	LINE, 146
	j	_98
;  147 |      case TC58FVT400FT_ID:
	.symb	LINE, 147
_58:
;  148 |         printf("	Flash = TC58FVT400FT\n");
	.symb	LINE, 148
	movh.a	a4,#@his(_21)
	lea	a4,[a4]@los(_21)
	callg	printf
;  149 |         uiFlashSize = MB_1_SIZE;
	.symb	LINE, 149
	movh	d15,#0x10			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  150 |         break;
	.symb	LINE, 150
	j	_98
;  151 |      case TC58FVB400FT_ID:
	.symb	LINE, 151
_59:
;  152 |         printf("	Flash = TC58FVB400FT\n");
	.symb	LINE, 152
	movh.a	a4,#@his(_22)
	lea	a4,[a4]@los(_22)
	callg	printf
;  153 |         uiFlashSize = MB_1_SIZE;
	.symb	LINE, 153
	movh	d15,#0x10			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  154 |         break;
	.symb	LINE, 154
	j	_98
;  155 |      case AM29LV400TB_ID:
	.symb	LINE, 155
_60:
;  156 |         printf("	Flash name = AM29LV400TB\n");
	.symb	LINE, 156
	movh.a	a4,#@his(_23)
	lea	a4,[a4]@los(_23)
	callg	printf
;  157 |         uiFlashSize = MB_1_SIZE;
	.symb	LINE, 157
	movh	d15,#0x10			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  158 |         break;
	.symb	LINE, 158
	j	_98
;  159 |      case AM29LV400BB_ID:
	.symb	LINE, 159
_61:
;  160 |         printf("	Flash name = AM29LV400BB\n");
	.symb	LINE, 160
	movh.a	a4,#@his(_24)
	lea	a4,[a4]@los(_24)
	callg	printf
;  161 |         uiFlashSize = MB_1_SIZE;
	.symb	LINE, 161
	movh	d15,#0x10			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  162 |         break;
	.symb	LINE, 162
	j	_98
;  163 |      case TC58FVT800FT_ID:
	.symb	LINE, 163
_62:
;  164 |         printf("	Flash name = TC58FVT800FT\n");
	.symb	LINE, 164
	movh.a	a4,#@his(_25)
	lea	a4,[a4]@los(_25)
	callg	printf
;  165 |         uiFlashSize = MB_2_SIZE;
	.symb	LINE, 165
	movh	d15,#0x20			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  166 |         break;
	.symb	LINE, 166
	j	_98
;  167 |      case TC58FVB800FT_ID:
	.symb	LINE, 167
_63:
;  168 |         printf("	Flash name = TC58FVB800FT\n");
	.symb	LINE, 168
	movh.a	a4,#@his(_26)
	lea	a4,[a4]@los(_26)
	callg	printf
;  169 |         uiFlashSize = MB_2_SIZE;
	.symb	LINE, 169
	movh	d15,#0x20			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  170 |         break;
	.symb	LINE, 170
	j	_98
;  171 |      case AM29LV800TB_ID:
	.symb	LINE, 171
_64:
;  172 |         printf("	Flash name = AM29LV800TB\n");
	.symb	LINE, 172
	movh.a	a4,#@his(_27)
	lea	a4,[a4]@los(_27)
	callg	printf
;  173 |         uiFlashSize = MB_2_SIZE;
	.symb	LINE, 173
	movh	d15,#0x20			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  174 |         break;
	.symb	LINE, 174
	j	_98
;  175 |      case AM29LV800BB_ID: 
	.symb	LINE, 175
_65:
;  176 |         printf("	Flash name = AM29LV800BB\n");
	.symb	LINE, 176
	movh.a	a4,#@his(_28)
	lea	a4,[a4]@los(_28)
	callg	printf
;  177 |         uiFlashSize = MB_2_SIZE;
	.symb	LINE, 177
	movh	d15,#0x20			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  178 |         break;
	.symb	LINE, 178
	j	_98
;  179 |      case AM29BL802C_ID:
	.symb	LINE, 179
_66:
;  180 |         printf("	Flash name = AM29BL802C\n");
	.symb	LINE, 180
	movh.a	a4,#@his(_29)
	lea	a4,[a4]@los(_29)
	callg	printf
;  181 |         uiFlashSize = MB_2_SIZE/4;
	.symb	LINE, 181
	movh	d15,#0x8			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  182 |         break;
	.symb	LINE, 182
	j	_98
;  183 |      case DT28F800F3T_ID:
	.symb	LINE, 183
_67:
;  184 |         printf("	Flash name = DT28F800F3T\n");
	.symb	LINE, 184
	movh.a	a4,#@his(_30)
	lea	a4,[a4]@los(_30)
	callg	printf
;  185 |         uiFlashSize = MB_2_SIZE;
	.symb	LINE, 185
	movh	d15,#0x20			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  186 |         break;
	.symb	LINE, 186
	j	_98
;  187 |      case DT28F800F3B_ID:
	.symb	LINE, 187
_68:
;  188 |         printf("	Flash name = DT28F800F3B\n");
	.symb	LINE, 188
	movh.a	a4,#@his(_31)
	lea	a4,[a4]@los(_31)
	callg	printf
;  189 |         uiFlashSize = MB_2_SIZE;
	.symb	LINE, 189
	movh	d15,#0x20			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  190 |         break;
	.symb	LINE, 190
	j	_98
;  191 |      case TC58FVT160FT_ID:
	.symb	LINE, 191
_69:
;  192 |         printf("	Flash name = TC58FVT160FT\n");
	.symb	LINE, 192
	movh.a	a4,#@his(_32)
	lea	a4,[a4]@los(_32)
	callg	printf
;  193 |         uiFlashSize = MB_4_SIZE;
	.symb	LINE, 193
	movh	d15,#0x40			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  194 |         break;
	.symb	LINE, 194
	j	_98
;  195 |      case TC58FVB160FT_ID:
	.symb	LINE, 195
_70:
;  196 |         printf("	Flash name = TC58FVB160FT\n");
	.symb	LINE, 196
	movh.a	a4,#@his(_33)
	lea	a4,[a4]@los(_33)
	callg	printf
;  197 |         uiFlashSize = MB_4_SIZE;
	.symb	LINE, 197
	movh	d15,#0x40			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  198 |         break;
	.symb	LINE, 198
	j	_98
;  199 |      case AM29LV160TB_ID:
	.symb	LINE, 199
_71:
;  200 |         printf("	Flash name = AM29LV160TB\n");
	.symb	LINE, 200
	movh.a	a4,#@his(_34)
	lea	a4,[a4]@los(_34)
	callg	printf
;  201 |         uiFlashSize = MB_4_SIZE/4;
	.symb	LINE, 201
	movh	d15,#0x10			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  202 |         break;
	.symb	LINE, 202
	j	_98
;  203 |      case AM29LV160BB_ID: 
	.symb	LINE, 203
_72:
;  204 |         printf("	Flash name = AM29LV160BB\n");
	.symb	LINE, 204
	movh.a	a4,#@his(_35)
	lea	a4,[a4]@los(_35)
	callg	printf
;  205 |         uiFlashSize = MB_4_SIZE;
	.symb	LINE, 205
	movh	d15,#0x40			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  206 |         break;
	.symb	LINE, 206
	j	_98
;  207 |      case AM29BL162C_ID:
	.symb	LINE, 207
_73:
;  208 |         printf("	Flash name = AM29BL162C\n");
	.symb	LINE, 208
	movh.a	a4,#@his(_36)
	lea	a4,[a4]@los(_36)
	callg	printf
;  209 |         uiFlashSize = MB_4_SIZE;
	.symb	LINE, 209
	movh	d15,#0x40			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  210 |         break;
	.symb	LINE, 210
	j	_98
;  211 |      case DT28F160F3B_ID:
	.symb	LINE, 211
_74:
;  212 |         printf("	Flash name = DT28F160F3B\n");
	.symb	LINE, 212
	movh.a	a4,#@his(_37)
	lea	a4,[a4]@los(_37)
	callg	printf
;  213 |         uiFlashSize = MB_4_SIZE;
	.symb	LINE, 213
	movh	d15,#0x40			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  214 |         break;
	.symb	LINE, 214
	j	_98
;  215 |      case DT28F160F3T_ID:
	.symb	LINE, 215
_75:
;  216 |         printf("	Flash name = DT28F160F3T\n");
	.symb	LINE, 216
	movh.a	a4,#@his(_38)
	lea	a4,[a4]@los(_38)
	callg	printf
;  217 |         uiFlashSize = MB_4_SIZE;
	.symb	LINE, 217
	movh	d15,#0x40			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  218 |         break;
	.symb	LINE, 218
	j	_98
;  219 |      case MBM29DL323TE_ID:
	.symb	LINE, 219
_76:
;  220 |         printf("	Flash name = MBM29DL323TE\n");
	.symb	LINE, 220
	movh.a	a4,#@his(_39)
	lea	a4,[a4]@los(_39)
	callg	printf
;  221 |         uiFlashSize = MB_8_SIZE;
	.symb	LINE, 221
	movh	d15,#0x80			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  222 |         break;
	.symb	LINE, 222
	j	_98
;  223 |      default:
	.symb	LINE, 223
_77:
;  224 |         printf("	Flash nicht bekannt!\n");
	.symb	LINE, 224
	movh.a	a4,#@his(_40)
	lea	a4,[a4]@los(_40)
	callg	printf
;  225 |		 ucErrorFlag=1;
	.symb	LINE, 225
	mov16	d15,#1				; ucErrorFlag
	st16.b	[sp]12,d15			; ucErrorFlag
;  226 |		 return(ucErrorFlag);
	.symb	LINE, 226
	ld.bu	d2,[sp]12			; ucErrorFlag
	ret16
;  227 |      }
	.symb	LINE, 227
_98:
;  228 |
;  229 |// ----------------- Preparing Flash for Dataline Test --------------------------------
;  230 |if (((uiFlashID>>16) != MANU_ID_AMD) && 
;  231 |	((uiFlashID>>16) != MANU_ID_TOSHIBA) &&
;  232 |	((uiFlashID>>16) != MANU_ID_FUJITSU)) 
	.symb	LINE, 232
	nop
	ld16.w	d15,[sp]16			; uiFlashID
	sh	d15,d15,#-16
	jeq	d15,#1,_101
	ld16.w	d15,[sp]16			; uiFlashID
	sh	d15,d15,#-16
	ne	d15,d15,#152
	jeq	d15,#0,_101
	ld16.w	d15,[sp]16			; uiFlashID
	sh	d15,d15,#-16
	jeq	d15,#4,_101
;  233 |	printf("	Sector erase not yet implemented for Intel Flashes. Skipping Flash-Dataline Test");
	.symb	LINE, 233
	movh.a	a4,#@his(_41)
	lea	a4,[a4]@los(_41)
	callg	printf
	j	_111
_101:
;  234 |else   
;  235 |{
;  236 |		printf("	Erasing sector 0 of Flash for dataline test...\n");
	.symb	LINE, 236
	movh.a	a4,#@his(_42)
	lea	a4,[a4]@los(_42)
	callg	printf
;  237 |		if ((AMD_Sector_Erase( uiBaseFlashAddrAtCS0 , uiBaseFlashAddrAtCS0 )) != SUCCESS)
	.symb	LINE, 237
	ld.w	d4,[sp]24			; uiBaseFlashAddrAtCS0
	ld.w	d5,[sp]24			; uiBaseFlashAddrAtCS0
	callg	AMD_Sector_Erase
	jeq	d2,#0,_102
;  238 |		{
;  239 |		printf("	ERROR erasing sector! \n");
	.symb	LINE, 239
	movh.a	a4,#@his(_43)
	lea	a4,[a4]@los(_43)
	callg	printf
;  240 |		ucErrorFlag=1;
	.symb	LINE, 240
	mov16	d15,#1				; ucErrorFlag
	st16.b	[sp]12,d15			; ucErrorFlag
;  241 |		return(ucErrorFlag);
	.symb	LINE, 241
	ld.bu	d2,[sp]12			; ucErrorFlag
	ret16
;  242 |		}
	.symb	LINE, 242
_102:
;  243 |// --------------------------- 	checking FLASH-Bank 1 for error on data ---------------------
;  244 |	// write test pattern
;  245 |	uiHilf = uiBaseFlashAddrAtCS0;
	.symb	LINE, 245
	nop
	ld16.w	d15,[sp]24			; uiBaseFlashAddrAtCS0
	st16.w	[sp]32,d15			; uiHilf
;  246 |	uiCnt = 0; 
	.symb	LINE, 246
	mov16	d15,#0				; uiCnt
	st16.w	[sp]36,d15			; uiCnt
;  247 |	while (uiCnt < 32)
	.symb	LINE, 247
	j	_106
_103:
;  248 |	      {   
;  249 |	      if (Program_Word(uiFlashID, uiHilf, 0x1<<uiCnt++,uiBaseFlashAddrAtCS0) != SUCCESS)
	.symb	LINE, 249
	nop
	ld.w	d4,[sp]16			; uiFlashID
	ld.w	d5,[sp]32			; uiHilf
	ld16.w	d15,[sp]36			; uiCnt
	ld.w	d7,[sp]36			; uiCnt
	add16	d7,#1				; uiCnt
	st.w	[sp]36,d7			; uiCnt
	mov16	d6,#1				; 1
	sha	d6,d6,d15
	ld.w	d7,[sp]24			; uiBaseFlashAddrAtCS0
	callg	Program_Word
	jeq	d2,#0,_104
;  250 |	         {
;  251 |	         // Failed to program.....try again...
;  252 |	         uiCnt--;
	.symb	LINE, 252
	ld16.w	d15,[sp]36			; uiCnt
	add16	d15,#-1				; uiCnt
	st16.w	[sp]36,d15			; uiCnt
;  253 |	         continue;
	.symb	LINE, 253
	j	_106
;  254 |	         }
	.symb	LINE, 254
_104:
;  255 |	      uiHilf += 4; // Remember, you are programming 32Bit Words!
	.symb	LINE, 255
	nop
	ld16.w	d15,[sp]32			; uiHilf
	add16	d15,#4				; uiHilf
	st16.w	[sp]32,d15			; uiHilf
	.symb	LINE, 247
_106:
	nop
	ld16.w	d15,[sp]36			; uiCnt
	lt.u	d15,d15,#32
	jne	d15,#0,_103
;  256 |	      }
;  257 |
;  258 |	// read test pattern
;  259 |	puiDest = (unsigned int *)(uiBaseFlashAddrAtCS0);
	.symb	LINE, 259
	ld16.w	d15,[sp]24			; uiBaseFlashAddrAtCS0
	mov16.a	a15,d15				; uiBaseFlashAddrAtCS0
	st16.a	[sp]40,a15			; puiDest
;  260 |	for (uiCnt = 0; uiCnt<32; uiCnt++)
	.symb	LINE, 260
	mov16	d15,#0				; uiCnt
	st16.w	[sp]36,d15			; uiCnt
	j	_109
_107:
;  261 |	{
;  262 |//		printf("DATA read=%08x at addr.=%08x check=%08x \n", *(unsigned int *)puiDest,puiDest,(0x1<<uiCnt) );
;  263 |		if (*puiDest++ != 0x1<<uiCnt) 
	.symb	LINE, 263
	nop
	ld.a	a7,[sp]40			; puiDest
	ld.a	a6,[sp]40			; puiDest
	add16.a	a6,#4				; puiDest
	st.a	[sp]40,a6			; puiDest
	ld16.w	d15,[a7]
	ld.w	d7,[sp]36			; uiCnt
	mov16	d6,#1				; 1
	sha	d7,d6,d7
	jeq	d15,d7,_108
;  264 |			{
;  265 |			ucErrorFlag=1;
	.symb	LINE, 265
	mov16	d15,#1				; ucErrorFlag
	st16.b	[sp]12,d15			; ucErrorFlag
;  266 |		    printf("	FLASH-BANK1 ERROR: DATA read=%08x at addr.=%08x check=%08x \n", *(unsigned int *)puiDest,puiDest,(0x1<<uiCnt) );
	.symb	LINE, 266
	movh.a	a4,#@his(_44)
	lea	a4,[a4]@los(_44)
	ld.a	a7,[sp]40			; puiDest
	ld16.w	d15,[a7]
	ld.a	a7,[sp]40			; puiDest
	ld.w	d7,[sp]36			; uiCnt
	mov16	d6,#1				; 1
	sha	d7,d6,d7
	st.w	[sp]8,d7
	st.a	[sp]4,a7			; puiDest
	st16.w	[sp],d15
	callg	printf
;  267 |			}
	.symb	LINE, 267
_108:
	.symb	LINE, 260
	nop
	ld16.w	d15,[sp]36			; uiCnt
	add16	d15,#1				; uiCnt
	st16.w	[sp]36,d15			; uiCnt
_109:
	nop
	ld16.w	d15,[sp]36			; uiCnt
	lt.u	d15,d15,#32
	jne	d15,#0,_107
;  268 |	}
;  269 |	if (ucErrorFlag == 0) printf("	Datalines are O.K. \n");
	.symb	LINE, 269
	ld16.bu	d15,[sp]12			; ucErrorFlag
	jne	d15,#0,_110			; ucErrorFlag
	movh.a	a4,#@his(_45)
	lea	a4,[a4]@los(_45)
	callg	printf
_110:
;  270 |
;  271 |}
	.symb	LINE, 271
_111:
;  272 |
;  273 |// --------------------------- 	checking FLASH-Bank 1 for error on address -------------------
;  274 |printf("	Erasing Flash for addressline test. This takes a while...\n");
	.symb	LINE, 274
	movh.a	a4,#@his(_46)
	lea	a4,[a4]@los(_46)
	callg	printf
;  275 |if (Chip_Erase(uiFlashID, uiBaseFlashAddrAtCS0) != SUCCESS)
	.symb	LINE, 275
	ld.w	d4,[sp]16			; uiFlashID
	ld.w	d5,[sp]24			; uiBaseFlashAddrAtCS0
	callg	Chip_Erase
	jeq	d2,#0,_112
;  276 |	{
;  277 |	printf("ERROR: Failed to erase Flash!!!");
	.symb	LINE, 277
	movh.a	a4,#@his(_47)
	lea	a4,[a4]@los(_47)
	callg	printf
;  278 |	ucErrorFlag = 1;
	.symb	LINE, 278
	mov16	d15,#1				; ucErrorFlag
	st16.b	[sp]12,d15			; ucErrorFlag
;  279 |	return(ucErrorFlag);
	.symb	LINE, 279
	ld.bu	d2,[sp]12			; ucErrorFlag
	ret16
;  280 |	}
	.symb	LINE, 280
_112:
;  281 |
;  282 |	// write test pattern
;  283 |	printf("	Programming testpattern...\n");
	.symb	LINE, 283
	movh.a	a4,#@his(_48)
	lea	a4,[a4]@los(_48)
	callg	printf
;  284 |	uiEndFlashTestCS0 = uiBaseFlashAddrAtCS0 + uiFlashSize;
	.symb	LINE, 284
	ld16.w	d15,[sp]24			; uiBaseFlashAddrAtCS0
	ld.w	d7,[sp]20			; uiFlashSize
	add16	d15,d7
	st16.w	[sp]28,d15			; uiEndFlashTestCS0
;  285 |	uiHilf = uiBaseFlashAddrAtCS0;
	.symb	LINE, 285
	ld16.w	d15,[sp]24			; uiBaseFlashAddrAtCS0
	st16.w	[sp]32,d15			; uiHilf
;  286 |	uiCnt = 0; 
	.symb	LINE, 286
	mov16	d15,#0				; uiCnt
	st16.w	[sp]36,d15			; uiCnt
;  287 |	while (uiHilf < uiEndFlashTestCS0)
	.symb	LINE, 287
	j	_116
_113:
;  288 |	      {   
;  289 |	      if (Program_Word(uiFlashID, uiHilf, uiCnt++,uiBaseFlashAddrAtCS0) != SUCCESS)
	.symb	LINE, 289
	nop
	ld.w	d4,[sp]16			; uiFlashID
	ld.w	d5,[sp]32			; uiHilf
	ld.w	d6,[sp]36			; uiCnt
	ld16.w	d15,[sp]36			; uiCnt
	add16	d15,#1				; uiCnt
	st16.w	[sp]36,d15			; uiCnt
	ld.w	d7,[sp]24			; uiBaseFlashAddrAtCS0
	callg	Program_Word
	jeq	d2,#0,_114
;  290 |	         {
;  291 |	         // Failed to program.....try again...
;  292 |	         uiCnt--;
	.symb	LINE, 292
	ld16.w	d15,[sp]36			; uiCnt
	add16	d15,#-1				; uiCnt
	st16.w	[sp]36,d15			; uiCnt
;  293 |	         continue;
	.symb	LINE, 293
	j	_116
;  294 |	         }
	.symb	LINE, 294
_114:
;  295 |	      uiHilf += 4; // Remember, you are programming 32Bit Words!
	.symb	LINE, 295
	nop
	ld16.w	d15,[sp]32			; uiHilf
	add16	d15,#4				; uiHilf
	st16.w	[sp]32,d15			; uiHilf
	.symb	LINE, 287
_116:
	nop
	ld16.w	d15,[sp]32			; uiHilf
	ld.w	d7,[sp]28			; uiEndFlashTestCS0
	jlt.u	d15,d7,_113
;  296 |	      }
;  297 |
;  298 |    // read test pattern
;  299 |	printf("	Reading testpattern...\n");
	.symb	LINE, 299
	movh.a	a4,#@his(_49)
	lea	a4,[a4]@los(_49)
	callg	printf
;  300 |	uiCnt=0;
	.symb	LINE, 300
	mov16	d15,#0				; uiCnt
	st16.w	[sp]36,d15			; uiCnt
;  301 |	for (puiDest=(unsigned int *)(uiBaseFlashAddrAtCS0); 
	.symb	LINE, 301
	ld16.w	d15,[sp]24			; uiBaseFlashAddrAtCS0
	mov16.a	a15,d15				; uiBaseFlashAddrAtCS0
	st16.a	[sp]40,a15			; puiDest
	j	_119
_117:
;  302 |		(puiDest < (unsigned int *)uiEndFlashTestCS0); puiDest++)
;  303 |	{
;  304 |//    printf("data read=%08x at ADDR.=%08x check=%08x \n", *(unsigned int *)puiDest,puiDest,uiCnt);
;  305 |		if (*puiDest != uiCnt++) 
	.symb	LINE, 305
	nop
	ld.a	a7,[sp]40			; puiDest
	ld16.w	d15,[a7]
	ld.w	d7,[sp]36			; uiCnt
	ld.w	d6,[sp]36			; uiCnt
	add16	d6,#1				; uiCnt
	st.w	[sp]36,d6			; uiCnt
	jeq	d15,d7,_118
;  306 |		{
;  307 |			ucErrorFlag=1;
	.symb	LINE, 307
	mov16	d15,#1				; ucErrorFlag
	st16.b	[sp]12,d15			; ucErrorFlag
;  308 |		    printf("	FLASH-BANK1 ERROR: data read=%08x at ADDR.=%08x check=%08x \n", *(unsigned int *)puiDest,puiDest,uiCnt);
	.symb	LINE, 308
	movh.a	a4,#@his(_50)
	lea	a4,[a4]@los(_50)
	ld.a	a7,[sp]40			; puiDest
	ld16.w	d15,[a7]
	ld.a	a7,[sp]40			; puiDest
	ld.w	d7,[sp]36			; uiCnt
	st.w	[sp]8,d7			; uiCnt
	st.a	[sp]4,a7			; puiDest
	st16.w	[sp],d15
	callg	printf
;  309 |		}
	.symb	LINE, 309
_118:
	.symb	LINE, 302
	nop
	ld.a	a7,[sp]40			; puiDest
	add16.a	a7,#4				; puiDest
	st.a	[sp]40,a7			; puiDest
_119:
	nop
	ld.a	a7,[sp]40			; puiDest
	ld16.w	d15,[sp]28			; uiEndFlashTestCS0
	mov16.a	a15,d15				; uiEndFlashTestCS0
	lt.a	d15,a7,a15
	jne	d15,#0,_117
;  310 |	}
;  311 |if (ucErrorFlag == 0) printf("	FLASH-BANK_1 O.K. \n");
	.symb	LINE, 311
	ld16.bu	d15,[sp]12			; ucErrorFlag
	jne	d15,#0,_120			; ucErrorFlag
	movh.a	a4,#@his(_51)
	lea	a4,[a4]@los(_51)
	callg	printf
_120:
;  312 |
;  313 |// Ende Flash-Test
;  314 |return(ucErrorFlag);
	.symb	LINE, 314
	nop
	ld.bu	d2,[sp]12			; ucErrorFlag
;  315 |}
	.symb	LINE, 315
_124:
	ret16
	.symb	EFUN
;  316 |
;  317 |//-------------------------------------------------------------------------------------
;  318 |
;  319 |//---------------------------- Test for Flash on /CS3 ---------------------------------
;  320 |
;  321 |unsigned char FLASH_TEST_BANK2 (void)
;  322 |{
	.symb	LINE, 322
	.symb	TYPE, 268, 'X', 8, #3, 26, 0
	.symb	GFUN, "FLASH_TEST_BANK2", FLASH_TEST_BANK2, #268, 0, 48, 0
	.symb	ALAB, FLASH_TEST_BANK2, #268
FLASH_TEST_BANK2:
	.symb	SOFF, 48
	.symb	IDEN, "ucErrorFlag", -36, #3, 131, 0x5
	.symb	IDEN, "uiFlashID", -32, #18, 131, 0x5
	.symb	IDEN, "uiFlashSize", -28, #18, 131, 0x5
	.symb	IDEN, "uiBaseFlashAddrAtCS3", -24, #18, 131, 0x5
	.symb	IDEN, "uiEndFlashTestCS3", -20, #18, 131, 0x5
	.symb	IDEN, "uiHilf", -16, #18, 131, 0x5
	.symb	IDEN, "uiCnt", -12, #18, 131, 0x5
	.symb	IDEN, "puiDest", -8, #267, 131, 0x5
	nop
	sub16.a	sp,#48
;  323 |
;  324 |unsigned char ucErrorFlag;
;  325 |unsigned int uiFlashID;
;  326 |unsigned int uiFlashSize;
;  327 |unsigned int uiBaseFlashAddrAtCS3;
;  328 |unsigned int uiEndFlashTestCS3;
;  329 |unsigned int uiHilf;
;  330 |unsigned int uiCnt;
;  331 |unsigned int *puiDest;
;  332 |
;  333 |ucErrorFlag = 0;
	.symb	LINE, 333
	mov16	d15,#0				; ucErrorFlag
	st16.b	[sp]12,d15			; ucErrorFlag
;  334 |uiFlashID=0;
	.symb	LINE, 334
	mov16	d15,#0				; uiFlashID
	st16.w	[sp]16,d15			; uiFlashID
;  335 |uiFlashSize = 0;
	.symb	LINE, 335
	mov16	d15,#0				; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  336 |uiBaseFlashAddrAtCS3 = 0xB0800000 ;
	.symb	LINE, 336
	movh	d15,#0xb080			; uiBaseFlashAddrAtCS3
	st16.w	[sp]24,d15			; uiBaseFlashAddrAtCS3
;  337 |uiEndFlashTestCS3 = 0;
	.symb	LINE, 337
	mov16	d15,#0				; uiEndFlashTestCS3
	st16.w	[sp]28,d15			; uiEndFlashTestCS3
;  338 |uiHilf = 0;
	.symb	LINE, 338
	mov16	d15,#0				; uiHilf
	st16.w	[sp]32,d15			; uiHilf
;  339 |
;  340 |
;  341 |printf("Testing FLASH at /CS3...\n");
	.symb	LINE, 341
	movh.a	a4,#@his(_125)
	lea	a4,[a4]@los(_125)
	callg	printf
;  342 |// Ist der Flash Hersteller der Testsoftware bekannt?
;  343 |uiFlashID = Read_ID( uiBaseFlashAddrAtCS3 );
	.symb	LINE, 343
	ld.w	d4,[sp]24			; uiBaseFlashAddrAtCS3
	callg	Read_ID
	st.w	[sp]16,d2			; uiFlashID
;  344 |if (((uiFlashID>>16) != MANU_ID_AMD) &&
;  345 |    ((uiFlashID>>16) != MANU_ID_TOSHIBA) &&
;  346 |    ((uiFlashID>>16) != MANU_ID_FUJITSU) &&
;  347 |    ((uiFlashID>>16) != MANU_ID_INTEL))
	.symb	LINE, 347
	ld16.w	d15,[sp]16			; uiFlashID
	sh	d15,d15,#-16
	jeq	d15,#1,_132
	ld16.w	d15,[sp]16			; uiFlashID
	sh	d15,d15,#-16
	ne	d15,d15,#152
	jeq	d15,#0,_132
	ld16.w	d15,[sp]16			; uiFlashID
	sh	d15,d15,#-16
	jeq	d15,#4,_132
	ld16.w	d15,[sp]16			; uiFlashID
	sh	d15,d15,#-16
	ne	d15,d15,#137
	jeq	d15,#0,_132
;  348 |    {
;  349 |    printf("	Unknown Manufacturer ID [%X]\n", uiFlashID>>16);
	.symb	LINE, 349
	movh.a	a4,#@his(_18)
	lea	a4,[a4]@los(_18)
	ld16.w	d15,[sp]16			; uiFlashID
	sh	d15,d15,#-16
	st16.w	[sp],d15
	callg	printf
;  350 |	ucErrorFlag=1;
	.symb	LINE, 350
	mov16	d15,#1				; ucErrorFlag
	st16.b	[sp]12,d15			; ucErrorFlag
;  351 |	return(ucErrorFlag);
	.symb	LINE, 351
	ld.bu	d2,[sp]12			; ucErrorFlag
	ret16
;  352 |    }
	.symb	LINE, 352
_132:
;  353 |
;  354 |// Ist der Flash-Typ bekannt?
;  355 |switch (uiFlashID & 0xFFFF)
	.symb	LINE, 355
	nop
	ld16.w	d15,[sp]16			; uiFlashID
	mov.u	d7,#65535			; 65535
	and16	d15,d7
	addi	d15,d15,#-72
	jeq	d15,#-5,_147			; case 67
	jeq	d15,#4,_136			; case 76
	jeq	d15,#7,_139			; case 79
	addi	d15,d15,#-127
	jeq	d15,#-5,_146			; case 194
	jeq	d15,#6,_135			; case 205
	jeq	d15,#7,_140			; case 206
	addi	d15,d15,#-8508
	jeq	d15,#0,_150			; case 8707
	addi	d15,d15,#-63
	jeq	d15,#-7,_133			; case 8763
	jeq	d15,#7,_149			; case 8777
	addi	d15,d15,#-18
	jeq	d15,#-4,_153			; case 8784
	jeq	d15,#7,_142			; case 8795
	addi	d15,d15,#-45
	jeq	d15,#0,_143			; case 8833
	addi	d15,d15,#-62
	jeq	d15,#-6,_137			; case 8889
	jeq	d15,#-5,_138			; case 8890
	jeq	d15,#0,_134			; case 8895
	jeq	d15,#5,_148			; case 8900
	addi	d15,d15,#-27
	jeq	d15,#0,_141			; case 8922
	addi	d15,d15,#-26138
	jeq	d15,#-3,_144			; case 35057
	jeq	d15,#-2,_145			; case 35058
	jeq	d15,#-1,_152			; case 35059
	jeq	d15,#0,_151			; case 35060
	j	_154				; default
;  356 |      {
;  357 |      case AM29LV200TB_ID:
	.symb	LINE, 357
_133:
;  358 |         printf("	Flash name = AM29LV200TB\n");
	.symb	LINE, 358
	movh.a	a4,#@his(_19)
	lea	a4,[a4]@los(_19)
	callg	printf
;  359 |         uiFlashSize = KB_512_SIZE;
	.symb	LINE, 359
	movh	d15,#0x8			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  360 |         break;
	.symb	LINE, 360
	j	_175
;  361 |      case AM29LV200BB_ID:
	.symb	LINE, 361
_134:
;  362 |         printf("	Flash = AM29LV200BB\n");
	.symb	LINE, 362
	movh.a	a4,#@his(_20)
	lea	a4,[a4]@los(_20)
	callg	printf
;  363 |         uiFlashSize = KB_512_SIZE;
	.symb	LINE, 363
	movh	d15,#0x8			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  364 |         break;
	.symb	LINE, 364
	j	_175
;  365 |      case TC58FVT400FT_ID:
	.symb	LINE, 365
_135:
;  366 |         printf("	Flash = TC58FVT400FT\n");
	.symb	LINE, 366
	movh.a	a4,#@his(_21)
	lea	a4,[a4]@los(_21)
	callg	printf
;  367 |         uiFlashSize = MB_1_SIZE;
	.symb	LINE, 367
	movh	d15,#0x10			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  368 |         break;
	.symb	LINE, 368
	j	_175
;  369 |      case TC58FVB400FT_ID:
	.symb	LINE, 369
_136:
;  370 |         printf("	Flash = TC58FVB400FT\n");
	.symb	LINE, 370
	movh.a	a4,#@his(_22)
	lea	a4,[a4]@los(_22)
	callg	printf
;  371 |         uiFlashSize = MB_1_SIZE;
	.symb	LINE, 371
	movh	d15,#0x10			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  372 |         break;
	.symb	LINE, 372
	j	_175
;  373 |      case AM29LV400TB_ID:
	.symb	LINE, 373
_137:
;  374 |         printf("	Flash name = AM29LV400TB\n");
	.symb	LINE, 374
	movh.a	a4,#@his(_23)
	lea	a4,[a4]@los(_23)
	callg	printf
;  375 |         uiFlashSize = MB_1_SIZE;
	.symb	LINE, 375
	movh	d15,#0x10			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  376 |         break;
	.symb	LINE, 376
	j	_175
;  377 |      case AM29LV400BB_ID:
	.symb	LINE, 377
_138:
;  378 |         printf("	Flash name = AM29LV400BB\n");
	.symb	LINE, 378
	movh.a	a4,#@his(_24)
	lea	a4,[a4]@los(_24)
	callg	printf
;  379 |         uiFlashSize = MB_1_SIZE;
	.symb	LINE, 379
	movh	d15,#0x10			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  380 |         break;
	.symb	LINE, 380
	j	_175
;  381 |      case TC58FVT800FT_ID:
	.symb	LINE, 381
_139:
;  382 |         printf("	Flash name = TC58FVT800FT\n");
	.symb	LINE, 382
	movh.a	a4,#@his(_25)
	lea	a4,[a4]@los(_25)
	callg	printf
;  383 |         uiFlashSize = MB_2_SIZE;
	.symb	LINE, 383
	movh	d15,#0x20			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  384 |         break;
	.symb	LINE, 384
	j	_175
;  385 |      case TC58FVB800FT_ID:
	.symb	LINE, 385
_140:
;  386 |         printf("	Flash name = TC58FVB800FT\n");
	.symb	LINE, 386
	movh.a	a4,#@his(_26)
	lea	a4,[a4]@los(_26)
	callg	printf
;  387 |         uiFlashSize = MB_2_SIZE;
	.symb	LINE, 387
	movh	d15,#0x20			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  388 |         break;
	.symb	LINE, 388
	j	_175
;  389 |      case AM29LV800TB_ID:
	.symb	LINE, 389
_141:
;  390 |         printf("	Flash name = AM29LV800TB\n");
	.symb	LINE, 390
	movh.a	a4,#@his(_27)
	lea	a4,[a4]@los(_27)
	callg	printf
;  391 |         uiFlashSize = MB_2_SIZE;
	.symb	LINE, 391
	movh	d15,#0x20			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  392 |         break;
	.symb	LINE, 392
	j	_175
;  393 |      case AM29LV800BB_ID: 
	.symb	LINE, 393
_142:
;  394 |         printf("	Flash name = AM29LV800BB\n");
	.symb	LINE, 394
	movh.a	a4,#@his(_28)
	lea	a4,[a4]@los(_28)
	callg	printf
;  395 |         uiFlashSize = MB_2_SIZE;
	.symb	LINE, 395
	movh	d15,#0x20			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  396 |         break;
	.symb	LINE, 396
	j	_175
;  397 |      case AM29BL802C_ID:
	.symb	LINE, 397
_143:
;  398 |         printf("	Flash name = AM29BL802C\n");
	.symb	LINE, 398
	movh.a	a4,#@his(_29)
	lea	a4,[a4]@los(_29)
	callg	printf
;  399 |         uiFlashSize = MB_2_SIZE/4;
	.symb	LINE, 399
	movh	d15,#0x8			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  400 |         break;
	.symb	LINE, 400
	j	_175
;  401 |      case DT28F800F3T_ID:
	.symb	LINE, 401
_144:
;  402 |         printf("	Flash name = DT28F800F3T\n");
	.symb	LINE, 402
	movh.a	a4,#@his(_30)
	lea	a4,[a4]@los(_30)
	callg	printf
;  403 |         uiFlashSize = MB_2_SIZE;
	.symb	LINE, 403
	movh	d15,#0x20			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  404 |         break;
	.symb	LINE, 404
	j	_175
;  405 |      case DT28F800F3B_ID:
	.symb	LINE, 405
_145:
;  406 |         printf("	Flash name = DT28F800F3B\n");
	.symb	LINE, 406
	movh.a	a4,#@his(_31)
	lea	a4,[a4]@los(_31)
	callg	printf
;  407 |         uiFlashSize = MB_2_SIZE;
	.symb	LINE, 407
	movh	d15,#0x20			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  408 |         break;
	.symb	LINE, 408
	j	_175
;  409 |      case TC58FVT160FT_ID:
	.symb	LINE, 409
_146:
;  410 |         printf("	Flash name = TC58FVT160FT\n");
	.symb	LINE, 410
	movh.a	a4,#@his(_32)
	lea	a4,[a4]@los(_32)
	callg	printf
;  411 |         uiFlashSize = MB_4_SIZE;
	.symb	LINE, 411
	movh	d15,#0x40			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  412 |         break;
	.symb	LINE, 412
	j	_175
;  413 |      case TC58FVB160FT_ID:
	.symb	LINE, 413
_147:
;  414 |         printf("	Flash name = TC58FVB160FT\n");
	.symb	LINE, 414
	movh.a	a4,#@his(_33)
	lea	a4,[a4]@los(_33)
	callg	printf
;  415 |         uiFlashSize = MB_4_SIZE;
	.symb	LINE, 415
	movh	d15,#0x40			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  416 |         break;
	.symb	LINE, 416
	j	_175
;  417 |      case AM29LV160TB_ID:
	.symb	LINE, 417
_148:
;  418 |         printf("	Flash name = AM29LV160TB\n");
	.symb	LINE, 418
	movh.a	a4,#@his(_34)
	lea	a4,[a4]@los(_34)
	callg	printf
;  419 |         uiFlashSize = MB_4_SIZE/4;
	.symb	LINE, 419
	movh	d15,#0x10			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  420 |         break;
	.symb	LINE, 420
	j	_175
;  421 |      case AM29LV160BB_ID: 
	.symb	LINE, 421
_149:
;  422 |         printf("	Flash name = AM29LV160BB\n");
	.symb	LINE, 422
	movh.a	a4,#@his(_35)
	lea	a4,[a4]@los(_35)
	callg	printf
;  423 |         uiFlashSize = MB_4_SIZE;
	.symb	LINE, 423
	movh	d15,#0x40			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  424 |         break;
	.symb	LINE, 424
	j	_175
;  425 |      case AM29BL162C_ID:
	.symb	LINE, 425
_150:
;  426 |         printf("	Flash name = AM29BL162C\n");
	.symb	LINE, 426
	movh.a	a4,#@his(_36)
	lea	a4,[a4]@los(_36)
	callg	printf
;  427 |         uiFlashSize = MB_4_SIZE;
	.symb	LINE, 427
	movh	d15,#0x40			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  428 |         break;
	.symb	LINE, 428
	j	_175
;  429 |      case DT28F160F3B_ID:
	.symb	LINE, 429
_151:
;  430 |         printf("	Flash name = DT28F160F3B\n");
	.symb	LINE, 430
	movh.a	a4,#@his(_37)
	lea	a4,[a4]@los(_37)
	callg	printf
;  431 |         uiFlashSize = MB_4_SIZE;
	.symb	LINE, 431
	movh	d15,#0x40			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  432 |         break;
	.symb	LINE, 432
	j	_175
;  433 |      case DT28F160F3T_ID:
	.symb	LINE, 433
_152:
;  434 |         printf("	Flash name = DT28F160F3T\n");
	.symb	LINE, 434
	movh.a	a4,#@his(_38)
	lea	a4,[a4]@los(_38)
	callg	printf
;  435 |         uiFlashSize = MB_4_SIZE;
	.symb	LINE, 435
	movh	d15,#0x40			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  436 |         break;
	.symb	LINE, 436
	j	_175
;  437 |      case MBM29DL323TE_ID:
	.symb	LINE, 437
_153:
;  438 |         printf("	Flash name = MBM29DL323TE\n");
	.symb	LINE, 438
	movh.a	a4,#@his(_39)
	lea	a4,[a4]@los(_39)
	callg	printf
;  439 |         uiFlashSize = MB_8_SIZE;
	.symb	LINE, 439
	movh	d15,#0x80			; uiFlashSize
	st16.w	[sp]20,d15			; uiFlashSize
;  440 |         break;
	.symb	LINE, 440
	j	_175
;  441 |      default:
	.symb	LINE, 441
_154:
;  442 |         printf("	Flash nicht bekannt!\n");
	.symb	LINE, 442
	movh.a	a4,#@his(_40)
	lea	a4,[a4]@los(_40)
	callg	printf
;  443 |		 ucErrorFlag=1;
	.symb	LINE, 443
	mov16	d15,#1				; ucErrorFlag
	st16.b	[sp]12,d15			; ucErrorFlag
;  444 |   		 return(ucErrorFlag);
	.symb	LINE, 444
	ld.bu	d2,[sp]12			; ucErrorFlag
	ret16
;  445 |      }
	.symb	LINE, 445
_175:
;  446 |
;  447 |// ----------------- Preparing Flash for Dataline Test --------------------------------
;  448 |if (((uiFlashID>>16) != MANU_ID_AMD) && 
;  449 |    ((uiFlashID>>16) != MANU_ID_TOSHIBA) &&
;  450 |	((uiFlashID>>16) != MANU_ID_FUJITSU)) 
	.symb	LINE, 450
	nop
	ld16.w	d15,[sp]16			; uiFlashID
	sh	d15,d15,#-16
	jeq	d15,#1,_178
	ld16.w	d15,[sp]16			; uiFlashID
	sh	d15,d15,#-16
	ne	d15,d15,#152
	jeq	d15,#0,_178
	ld16.w	d15,[sp]16			; uiFlashID
	sh	d15,d15,#-16
	jeq	d15,#4,_178
;  451 |	printf("	Sector erase not yet implemented for Intel Flashes. Skipping Flash-Dataline Test");
	.symb	LINE, 451
	movh.a	a4,#@his(_41)
	lea	a4,[a4]@los(_41)
	callg	printf
	j	_188
_178:
;  452 |else   
;  453 |{
;  454 |		printf("	Erasing sector 0 of Flash for dataline test...\n");
	.symb	LINE, 454
	movh.a	a4,#@his(_42)
	lea	a4,[a4]@los(_42)
	callg	printf
;  455 |		if ((AMD_Sector_Erase( uiBaseFlashAddrAtCS3 , uiBaseFlashAddrAtCS3 )) != SUCCESS)
	.symb	LINE, 455
	ld.w	d4,[sp]24			; uiBaseFlashAddrAtCS3
	ld.w	d5,[sp]24			; uiBaseFlashAddrAtCS3
	callg	AMD_Sector_Erase
	jeq	d2,#0,_179
;  456 |		{
;  457 |		printf("	ERROR erasing sector! \n");
	.symb	LINE, 457
	movh.a	a4,#@his(_43)
	lea	a4,[a4]@los(_43)
	callg	printf
;  458 |		ucErrorFlag=1;
	.symb	LINE, 458
	mov16	d15,#1				; ucErrorFlag
	st16.b	[sp]12,d15			; ucErrorFlag
;  459 |		return(ucErrorFlag);
	.symb	LINE, 459
	ld.bu	d2,[sp]12			; ucErrorFlag
	ret16
;  460 |		}
	.symb	LINE, 460
_179:
;  461 |// --------------------------- 	checking FLASH-Bank 2 for error on data ---------------------
;  462 |	// write test pattern
;  463 |	uiHilf = uiBaseFlashAddrAtCS3;
	.symb	LINE, 463
	nop
	ld16.w	d15,[sp]24			; uiBaseFlashAddrAtCS3
	st16.w	[sp]32,d15			; uiHilf
;  464 |	uiCnt = 0; 
	.symb	LINE, 464
	mov16	d15,#0				; uiCnt
	st16.w	[sp]36,d15			; uiCnt
;  465 |	while (uiCnt < 32)
	.symb	LINE, 465
	j	_183
_180:
;  466 |	      {   
;  467 |	      if (Program_Word(uiFlashID, uiHilf, 0x1<<uiCnt++,uiBaseFlashAddrAtCS3) != SUCCESS)
	.symb	LINE, 467
	nop
	ld.w	d4,[sp]16			; uiFlashID
	ld.w	d5,[sp]32			; uiHilf
	ld16.w	d15,[sp]36			; uiCnt
	ld.w	d7,[sp]36			; uiCnt
	add16	d7,#1				; uiCnt
	st.w	[sp]36,d7			; uiCnt
	mov16	d6,#1				; 1
	sha	d6,d6,d15
	ld.w	d7,[sp]24			; uiBaseFlashAddrAtCS3
	callg	Program_Word
	jeq	d2,#0,_181
;  468 |	         {
;  469 |	         // Failed to program.....try again...
;  470 |	         uiCnt--;
	.symb	LINE, 470
	ld16.w	d15,[sp]36			; uiCnt
	add16	d15,#-1				; uiCnt
	st16.w	[sp]36,d15			; uiCnt
;  471 |	         continue;
	.symb	LINE, 471
	j	_183
;  472 |	         }
	.symb	LINE, 472
_181:
;  473 |	      uiHilf += 4; // Remember, you are programming 32Bit Words!
	.symb	LINE, 473
	nop
	ld16.w	d15,[sp]32			; uiHilf
	add16	d15,#4				; uiHilf
	st16.w	[sp]32,d15			; uiHilf
	.symb	LINE, 465
_183:
	nop
	ld16.w	d15,[sp]36			; uiCnt
	lt.u	d15,d15,#32
	jne	d15,#0,_180
;  474 |	      }
;  475 |
;  476 |	// read test pattern
;  477 |	puiDest = (unsigned int *)(uiBaseFlashAddrAtCS3);
	.symb	LINE, 477
	ld16.w	d15,[sp]24			; uiBaseFlashAddrAtCS3
	mov16.a	a15,d15				; uiBaseFlashAddrAtCS3
	st16.a	[sp]40,a15			; puiDest
;  478 |	for (uiCnt = 0; uiCnt<32; uiCnt++)
	.symb	LINE, 478
	mov16	d15,#0				; uiCnt
	st16.w	[sp]36,d15			; uiCnt
	j	_186
_184:
;  479 |	{
;  480 |//		printf("DATA read=%08x at addr.=%08x check=%08x \n", *(unsigned int *)puiDest,puiDest,(0x1<<uiCnt) );
;  481 |		if (*puiDest++ != 0x1<<uiCnt) 
	.symb	LINE, 481
	nop
	ld.a	a7,[sp]40			; puiDest
	ld.a	a6,[sp]40			; puiDest
	add16.a	a6,#4				; puiDest
	st.a	[sp]40,a6			; puiDest
	ld16.w	d15,[a7]
	ld.w	d7,[sp]36			; uiCnt
	mov16	d6,#1				; 1
	sha	d7,d6,d7
	jeq	d15,d7,_185
;  482 |			{
;  483 |			ucErrorFlag=1;
	.symb	LINE, 483
	mov16	d15,#1				; ucErrorFlag
	st16.b	[sp]12,d15			; ucErrorFlag
;  484 |		    printf("	FLASH-BANK2 ERROR: DATA read=%08x at addr.=%08x check=%08x \n", *(unsigned int *)puiDest,puiDest,(0x1<<uiCnt) );
	.symb	LINE, 484
	movh.a	a4,#@his(_126)
	lea	a4,[a4]@los(_126)
	ld.a	a7,[sp]40			; puiDest
	ld16.w	d15,[a7]
	ld.a	a7,[sp]40			; puiDest
	ld.w	d7,[sp]36			; uiCnt
	mov16	d6,#1				; 1
	sha	d7,d6,d7
	st.w	[sp]8,d7
	st.a	[sp]4,a7			; puiDest
	st16.w	[sp],d15
	callg	printf
;  485 |			}
	.symb	LINE, 485
_185:
	.symb	LINE, 478
	nop
	ld16.w	d15,[sp]36			; uiCnt
	add16	d15,#1				; uiCnt
	st16.w	[sp]36,d15			; uiCnt
_186:
	nop
	ld16.w	d15,[sp]36			; uiCnt
	lt.u	d15,d15,#32
	jne	d15,#0,_184
;  486 |	}
;  487 |	if (ucErrorFlag == 0) printf("	Datalines are O.K. \n");
	.symb	LINE, 487
	ld16.bu	d15,[sp]12			; ucErrorFlag
	jne	d15,#0,_187			; ucErrorFlag
	movh.a	a4,#@his(_45)
	lea	a4,[a4]@los(_45)
	callg	printf
_187:
;  488 |
;  489 |}
	.symb	LINE, 489
_188:
;  490 |
;  491 |// --------------------------- 	checking FLASH-Bank 2 for error on address -------------------
;  492 |printf("	Erasing Flash for addressline test. This takes a while...\n");
	.symb	LINE, 492
	movh.a	a4,#@his(_46)
	lea	a4,[a4]@los(_46)
	callg	printf
;  493 |if (Chip_Erase(uiFlashID, uiBaseFlashAddrAtCS3) != SUCCESS)
	.symb	LINE, 493
	ld.w	d4,[sp]16			; uiFlashID
	ld.w	d5,[sp]24			; uiBaseFlashAddrAtCS3
	callg	Chip_Erase
	jeq	d2,#0,_189
;  494 |	{
;  495 |	printf("ERROR: Failed to erase Flash!!!");
	.symb	LINE, 495
	movh.a	a4,#@his(_47)
	lea	a4,[a4]@los(_47)
	callg	printf
;  496 |	ucErrorFlag = 1;
	.symb	LINE, 496
	mov16	d15,#1				; ucErrorFlag
	st16.b	[sp]12,d15			; ucErrorFlag
;  497 |	return(ucErrorFlag);
	.symb	LINE, 497
	ld.bu	d2,[sp]12			; ucErrorFlag
	ret16
;  498 |	}
	.symb	LINE, 498
_189:
;  499 |
;  500 |	// write test pattern
;  501 |	printf("	Programming testpattern...\n");
	.symb	LINE, 501
	movh.a	a4,#@his(_48)
	lea	a4,[a4]@los(_48)
	callg	printf
;  502 |	uiEndFlashTestCS3 = uiBaseFlashAddrAtCS3 + uiFlashSize;
	.symb	LINE, 502
	ld16.w	d15,[sp]24			; uiBaseFlashAddrAtCS3
	ld.w	d7,[sp]20			; uiFlashSize
	add16	d15,d7
	st16.w	[sp]28,d15			; uiEndFlashTestCS3
;  503 |	uiHilf = uiBaseFlashAddrAtCS3;
	.symb	LINE, 503
	ld16.w	d15,[sp]24			; uiBaseFlashAddrAtCS3
	st16.w	[sp]32,d15			; uiHilf
;  504 |	uiCnt = 0; 
	.symb	LINE, 504
	mov16	d15,#0				; uiCnt
	st16.w	[sp]36,d15			; uiCnt
;  505 |	while (uiHilf < uiEndFlashTestCS3)
	.symb	LINE, 505
	j	_193
_190:
;  506 |	      {   
;  507 |	      if (Program_Word(uiFlashID, uiHilf, uiCnt++,uiBaseFlashAddrAtCS3) != SUCCESS)
	.symb	LINE, 507
	nop
	ld.w	d4,[sp]16			; uiFlashID
	ld.w	d5,[sp]32			; uiHilf
	ld.w	d6,[sp]36			; uiCnt
	ld16.w	d15,[sp]36			; uiCnt
	add16	d15,#1				; uiCnt
	st16.w	[sp]36,d15			; uiCnt
	ld.w	d7,[sp]24			; uiBaseFlashAddrAtCS3
	callg	Program_Word
	jeq	d2,#0,_191
;  508 |	         {
;  509 |	         // Failed to program.....try again...
;  510 |	         uiCnt--;
	.symb	LINE, 510
	ld16.w	d15,[sp]36			; uiCnt
	add16	d15,#-1				; uiCnt
	st16.w	[sp]36,d15			; uiCnt
;  511 |	         continue;
	.symb	LINE, 511
	j	_193
;  512 |	         }
	.symb	LINE, 512
_191:
;  513 |	      uiHilf += 4; // Remember, you are programming 32Bit Words!
	.symb	LINE, 513
	nop
	ld16.w	d15,[sp]32			; uiHilf
	add16	d15,#4				; uiHilf
	st16.w	[sp]32,d15			; uiHilf
	.symb	LINE, 505
_193:
	nop
	ld16.w	d15,[sp]32			; uiHilf
	ld.w	d7,[sp]28			; uiEndFlashTestCS3
	jlt.u	d15,d7,_190
;  514 |	      }
;  515 |
;  516 |    // read test pattern
;  517 |	printf("	Reading testpattern...\n");
	.symb	LINE, 517
	movh.a	a4,#@his(_49)
	lea	a4,[a4]@los(_49)
	callg	printf
;  518 |	uiCnt=0;
	.symb	LINE, 518
	mov16	d15,#0				; uiCnt
	st16.w	[sp]36,d15			; uiCnt
;  519 |	for (puiDest=(unsigned int *)(uiBaseFlashAddrAtCS3); 
	.symb	LINE, 519
	ld16.w	d15,[sp]24			; uiBaseFlashAddrAtCS3
	mov16.a	a15,d15				; uiBaseFlashAddrAtCS3
	st16.a	[sp]40,a15			; puiDest
	j	_196
_194:
;  520 |		(puiDest < (unsigned int *)uiEndFlashTestCS3); puiDest++)
;  521 |	{
;  522 |//    printf("data read=%08x at ADDR.=%08x check=%08x \n", *(unsigned int *)puiDest,puiDest,uiCnt);
;  523 |		if (*puiDest != uiCnt++) 
	.symb	LINE, 523
	nop
	ld.a	a7,[sp]40			; puiDest
	ld16.w	d15,[a7]
	ld.w	d7,[sp]36			; uiCnt
	ld.w	d6,[sp]36			; uiCnt
	add16	d6,#1				; uiCnt
	st.w	[sp]36,d6			; uiCnt
	jeq	d15,d7,_195
;  524 |		{
;  525 |			ucErrorFlag=1;
	.symb	LINE, 525
	mov16	d15,#1				; ucErrorFlag
	st16.b	[sp]12,d15			; ucErrorFlag
;  526 |		    printf("	FLASH-BANK2 ERROR: data read=%08x at ADDR.=%08x check=%08x \n", *(unsigned int *)puiDest,puiDest,uiCnt);
	.symb	LINE, 526
	movh.a	a4,#@his(_127)
	lea	a4,[a4]@los(_127)
	ld.a	a7,[sp]40			; puiDest
	ld16.w	d15,[a7]
	ld.a	a7,[sp]40			; puiDest
	ld.w	d7,[sp]36			; uiCnt
	st.w	[sp]8,d7			; uiCnt
	st.a	[sp]4,a7			; puiDest
	st16.w	[sp],d15
	callg	printf
;  527 |		}
	.symb	LINE, 527
_195:
	.symb	LINE, 520
	nop
	ld.a	a7,[sp]40			; puiDest
	add16.a	a7,#4				; puiDest
	st.a	[sp]40,a7			; puiDest
_196:
	nop
	ld.a	a7,[sp]40			; puiDest
	ld16.w	d15,[sp]28			; uiEndFlashTestCS3
	mov16.a	a15,d15				; uiEndFlashTestCS3
	lt.a	d15,a7,a15
	jne	d15,#0,_194
;  528 |	}
;  529 |if (ucErrorFlag == 0) printf("	FLASH-BANK_2 O.K. \n");
	.symb	LINE, 529
	ld16.bu	d15,[sp]12			; ucErrorFlag
	jne	d15,#0,_197			; ucErrorFlag
	movh.a	a4,#@his(_128)
	lea	a4,[a4]@los(_128)
	callg	printf
_197:
;  530 |
;  531 |// Ende Flash-Test
;  532 |return(ucErrorFlag);
	.symb	LINE, 532
	nop
	ld.bu	d2,[sp]12			; ucErrorFlag
;  533 |}
	.symb	LINE, 533
_201:
	ret16
	.symb	EFUN
;  534 |
;  535 |// ====================================================================================
;  536 |
;  537 |// Liest den Manufacturer Code und die Device ID des Flashes aus.
;  538 |// Rückgabewert:  Bate 0 = Device ID ; Byte 1 = Manufactorer ID 
;  539 |unsigned int Read_ID( unsigned int uiFlashBase )
;  540 |{
	.symb	LINE, 540
	.symb	TYPE, 269, 'X', 8, #18, 26, 1, #18
	.symb	GFUN, "Read_ID", Read_ID, #269, 0, 16, 0
	.symb	ALAB, Read_ID, #269
Read_ID:
	.symb	SOFF, 16
	.symb	LTIM, "uiFlashBase", 4, 0, 0x8cd
	.symb	IDEN, "uiFlashBase", 4, #18, 0, 0x80d
	.symb	IDEN, "uiID", -12, #18, 131, 0x5
	.symb	LTIM, "uiFlashBase", 4, 0, 0x84d
	.symb	LTIM, "uiFlashBase", -16, 131, 0x8c5
	.symb	LTIM, "uiFlashBase", -16, 131, 0x845
	.symb	LTIM, "uiFlashBase", 4, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 4, 0, 0x84d
	.symb	LTIM, "uiFlashBase", 4, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 4, 0, 0x84d
	nop
	sub16.a	sp,#16
;  541 |	unsigned int uiID = 0;;
	.symb	LINE, 541
	st16.w	[sp],d4				; uiFlashBase
	mov16	d15,#0				; uiID
	st16.w	[sp]4,d15			; uiID
;  542 |
;  543 |	uiID = AMD_Flash_ID( uiFlashBase );
	.symb	LINE, 543
	ld16.w	d4,[sp]				; uiFlashBase
	callg	AMD_Flash_ID
	st.w	[sp]4,d2			; uiID
;  544 |
;  545 |	if (((uiID>>16) != MANU_ID_AMD) && ((uiID>>16) != MANU_ID_TOSHIBA) 
;  546 |			&& ((uiID>>16) != MANU_ID_FUJITSU)) uiID = Intel_Flash_ID(uiFlashBase);
	.symb	LINE, 546
	ld16.w	d15,[sp]4			; uiID
	sh	d15,d15,#-16
	jeq	d15,#1,_204
	ld16.w	d15,[sp]4			; uiID
	sh	d15,d15,#-16
	ne	d15,d15,#152
	jeq	d15,#0,_204
	ld16.w	d15,[sp]4			; uiID
	sh	d15,d15,#-16
	jeq	d15,#4,_204
	ld16.w	d4,[sp]				; uiFlashBase
	callg	Intel_Flash_ID
	st.w	[sp]4,d2			; uiID
_204:
;  547 |
;  548 |	return uiID;
	.symb	LINE, 548
	nop
	ld.w	d2,[sp]4			; uiID
;  549 |}
	.symb	LINE, 549
_205:
	ret16
	.symb	EFUN
;  550 |
;  551 |unsigned int Chip_Erase(unsigned int uiID, unsigned int uiFlashBase)
;  552 |{
	.symb	LINE, 552
	.symb	TYPE, 270, 'X', 8, #18, 26, 2, #18, #18
	.symb	GFUN, "Chip_Erase", Chip_Erase, #270, 0, 16, 0
	.symb	ALAB, Chip_Erase, #270
Chip_Erase:
	.symb	SOFF, 16
	.symb	LTIM, "uiID", 4, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 5, 0, 0x8cd
	.symb	IDEN, "uiID", 4, #18, 0, 0x80d
	.symb	IDEN, "uiFlashBase", 5, #18, 0, 0x80d
	.symb	IDEN, "uiRetVal", -8, #18, 131, 0x5
	.symb	LTIM, "uiFlashBase", 5, 0, 0x84d
	.symb	LTIM, "uiFlashBase", -16, 131, 0x8c5
	.symb	LTIM, "uiID", 4, 0, 0x84d
	.symb	LTIM, "uiID", -12, 131, 0x8c5
	.symb	LTIM, "uiID", -12, 131, 0x845
	.symb	LTIM, "uiID", 15, 0, 0x8cd
	.symb	LTIM, "uiID", 15, 0, 0x84d
	.symb	LTIM, "uiID", 4, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", -16, 131, 0x845
	.symb	LTIM, "uiFlashBase", 5, 0, 0x8cd
	.symb	LTIM, "uiID", 4, 0, 0x84d
	.symb	LTIM, "uiFlashBase", 5, 0, 0x84d
	nop
	sub16.a	sp,#16
;  553 |	unsigned int uiRetVal=0;
	.symb	LINE, 553
	st16.w	[sp],d5				; uiFlashBase
	st.w	[sp]4,d4			; uiID
	mov16	d15,#0				; uiRetVal
	st16.w	[sp]8,d15			; uiRetVal
;  554 |
;  555 |	if ((uiID>>16) == MANU_ID_INTEL) uiRetVal = Intel_Chip_Erase(uiID, uiFlashBase);
	.symb	LINE, 555
	ld16.w	d15,[sp]4			; uiID
	sh	d15,d15,#-16
	eq	d15,d15,#137
	jeq	d15,#0,_206
	ld.w	d4,[sp]4			; uiID
	ld16.w	d5,[sp]				; uiFlashBase
	callg	Intel_Chip_Erase
	st.w	[sp]8,d2			; uiRetVal
	j	_207
_206:
	.symb	LTIM, "uiFlashBase", 4, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 4, 0, 0x84d
;  556 |	else uiRetVal = AMD_Chip_Erase(uiFlashBase);
	.symb	LINE, 556
	nop
	ld16.w	d4,[sp]				; uiFlashBase
	callg	AMD_Chip_Erase
	st.w	[sp]8,d2			; uiRetVal
_207:
;  557 |
;  558 |	return uiRetVal;
	.symb	LINE, 558
	nop
	ld.w	d2,[sp]8			; uiRetVal
;  559 |}
	.symb	LINE, 559
_208:
	ret16
	.symb	EFUN
;  560 |
;  561 |unsigned int Program_Word(unsigned int uiID, unsigned int uiAddress, unsigned int uiValue, unsigned int uiFlashBase )
;  562 |{
	.symb	LINE, 562
	.symb	TYPE, 271, 'X', 8, #18, 26, 4, #18, #18, #18, #18
	.symb	GFUN, "Program_Word", Program_Word, #271, 0, 32, 0
	.symb	ALAB, Program_Word, #271
Program_Word:
	.symb	SOFF, 32
	.symb	LTIM, "uiAddress", 5, 0, 0x8cd
	.symb	LTIM, "uiValue", 6, 0, 0x8cd
	.symb	LTIM, "uiID", 4, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 7, 0, 0x8cd
	.symb	IDEN, "uiID", 4, #18, 0, 0x80d
	.symb	IDEN, "uiAddress", 5, #18, 0, 0x80d
	.symb	IDEN, "uiValue", 6, #18, 0, 0x80d
	.symb	IDEN, "uiFlashBase", 7, #18, 0, 0x80d
	.symb	IDEN, "uiRetVal", -16, #18, 131, 0x5
	.symb	LTIM, "uiFlashBase", 7, 0, 0x84d
	.symb	LTIM, "uiFlashBase", -32, 131, 0x8c5
	.symb	LTIM, "uiValue", 6, 0, 0x84d
	.symb	LTIM, "uiValue", -28, 131, 0x8c5
	.symb	LTIM, "uiAddress", 5, 0, 0x84d
	.symb	LTIM, "uiAddress", -24, 131, 0x8c5
	.symb	LTIM, "uiID", 4, 0, 0x84d
	.symb	LTIM, "uiID", -20, 131, 0x8c5
	.symb	LTIM, "uiID", -20, 131, 0x845
	.symb	LTIM, "uiID", 15, 0, 0x8cd
	.symb	LTIM, "uiID", 15, 0, 0x84d
	.symb	LTIM, "uiAddress", -24, 131, 0x845
	.symb	LTIM, "uiAddress", 4, 0, 0x8cd
	.symb	LTIM, "uiValue", -28, 131, 0x845
	.symb	LTIM, "uiValue", 5, 0, 0x8cd
	.symb	LTIM, "uiAddress", 4, 0, 0x84d
	.symb	LTIM, "uiValue", 5, 0, 0x84d
	nop
	sub16.a	sp,#32
;  563 |	unsigned int uiRetVal;
	.symb	LINE, 563
	st16.w	[sp],d7				; uiFlashBase
	st.w	[sp]4,d6			; uiValue
	st.w	[sp]8,d5			; uiAddress
	st.w	[sp]12,d4			; uiID
;  564 |
;  565 |	if ((uiID>>16) == MANU_ID_INTEL) uiRetVal = Intel_Program_Word(uiAddress, uiValue);
	.symb	LINE, 565
	ld16.w	d15,[sp]12			; uiID
	sh	d15,d15,#-16
	eq	d15,d15,#137
	jeq	d15,#0,_209
	ld.w	d4,[sp]8			; uiAddress
	ld.w	d5,[sp]4			; uiValue
	callg	Intel_Program_Word
	st.w	[sp]16,d2			; uiRetVal
	j	_210
_209:
	.symb	LTIM, "uiAddress", 4, 0, 0x8cd
	.symb	LTIM, "uiValue", 5, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", -32, 131, 0x845
	.symb	LTIM, "uiFlashBase", 6, 0, 0x8cd
	.symb	LTIM, "uiAddress", 4, 0, 0x84d
	.symb	LTIM, "uiValue", 5, 0, 0x84d
	.symb	LTIM, "uiFlashBase", 6, 0, 0x84d
;  566 |	else uiRetVal = AMD_Program_Word(uiAddress, uiValue, uiFlashBase);
	.symb	LINE, 566
	nop
	ld.w	d4,[sp]8			; uiAddress
	ld.w	d5,[sp]4			; uiValue
	ld16.w	d6,[sp]				; uiFlashBase
	callg	AMD_Program_Word
	st.w	[sp]16,d2			; uiRetVal
_210:
;  567 |
;  568 |	return uiRetVal;
	.symb	LINE, 568
	nop
	ld.w	d2,[sp]16			; uiRetVal
;  569 |}
	.symb	LINE, 569
_211:
	ret16
	.symb	EFUN
;  570 |
;  571 |unsigned int AMD_Flash_ID( unsigned int uiFlashBase )
;  572 |{
	.symb	LINE, 572
	.symb	TYPE, 272, 'X', 8, #18, 26, 1, #18
	.symb	GFUN, "AMD_Flash_ID", AMD_Flash_ID, #272, 0, 16, 0
	.symb	ALAB, AMD_Flash_ID, #272
AMD_Flash_ID:
	.symb	SOFF, 16
	.symb	LTIM, "uiFlashBase", 4, 0, 0x8cd
	.symb	IDEN, "uiFlashBase", 4, #18, 0, 0x80d
	.symb	IDEN, "puiAddress", -12, #267, 131, 0x5
	.symb	IDEN, "uiData", -8, #18, 131, 0x5
	.symb	LTIM, "uiFlashBase", 4, 0, 0x84d
	.symb	LTIM, "uiFlashBase", -16, 131, 0x8c5
	.symb	IDEN, "uiHelp", -4, #18, 131, 0x5
	.symb	LTIM, "uiFlashBase", -16, 131, 0x845
	.symb	LTIM, "uiFlashBase", 15, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 15, 0, 0x84d
	.symb	LTIM, "uiFlashBase", 15, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 15, 0, 0x84d
	.symb	LTIM, "uiFlashBase", 15, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 15, 0, 0x84d
	.symb	LTIM, "uiFlashBase", 15, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 15, 0, 0x84d
	nop
	sub16.a	sp,#16
;  573 |	register unsigned int *puiAddress;
;  574 |	register unsigned int uiData = 0x0;
	.symb	LINE, 574
	st16.w	[sp],d4				; uiFlashBase
	mov16	d15,#0				; uiData
	st16.w	[sp]8,d15			; uiData
;  575 |	register unsigned int uiHelp = 0x0;
	.symb	LINE, 575
	mov16	d15,#0				; uiHelp
	st16.w	[sp]12,d15			; uiHelp
;  576 |	/* first bus cycle */
;  577 |	puiAddress = (unsigned int *)(SETUP_ADDR+uiFlashBase);
	.symb	LINE, 577
	ld16.w	d15,[sp]			; uiFlashBase
	addi	d15,d15,#5460
	mov16.a	a15,d15
	st16.a	[sp]4,a15			; puiAddress
;  578 |	*puiAddress = AMDSETUP;
	.symb	LINE, 578
	ld.a	a7,[sp]4			; puiAddress
	mov.u	d15,#0xaa			; 11141290
	addih	d15,d15,#0xaa			; 11141290
	st16.w	[a7],d15			; puiAddress
;  579 |	/* second bus cycle */
;  580 |	puiAddress = (unsigned int *)(UNLOCK_ADDR+uiFlashBase);
	.symb	LINE, 580
	ld16.w	d15,[sp]			; uiFlashBase
	addi	d15,d15,#2728
	mov16.a	a15,d15
	st16.a	[sp]4,a15			; puiAddress
;  581 |	*puiAddress = AMDUNLOCK;
	.symb	LINE, 581
	ld.a	a7,[sp]4			; puiAddress
	mov.u	d15,#0x55			; 5570645
	addih	d15,d15,#0x55			; 5570645
	st16.w	[a7],d15			; puiAddress
;  582 |	/* third bus cycle */
;  583 |	puiAddress = (unsigned int *)(SETUP_ADDR+uiFlashBase);
	.symb	LINE, 583
	ld16.w	d15,[sp]			; uiFlashBase
	addi	d15,d15,#5460
	mov16.a	a15,d15
	st16.a	[sp]4,a15			; puiAddress
;  584 |	*puiAddress = AMDREAD_ID;
	.symb	LINE, 584
	ld.a	a7,[sp]4			; puiAddress
	mov.u	d15,#0x90			; 9437328
	addih	d15,d15,#0x90			; 9437328
	st16.w	[a7],d15			; puiAddress
;  585 |	puiAddress = (unsigned int *)(uiFlashBase);
	.symb	LINE, 585
	ld16.w	d15,[sp]			; uiFlashBase
	mov16.a	a15,d15				; uiFlashBase
	st16.a	[sp]4,a15			; puiAddress
;  586 |	uiData = *puiAddress;
	.symb	LINE, 586
	ld.a	a7,[sp]4			; puiAddress
	ld16.w	d15,[a7]
	st16.w	[sp]8,d15			; uiData
;  587 |	uiHelp = (uiData & 0xffff0000);
	.symb	LINE, 587
	ld16.w	d15,[sp]8			; uiData
	movh	d7,#0xffff			; -65536
	and16	d15,d7
	st16.w	[sp]12,d15			; uiHelp
;  588 |	if ((uiData & 0xffff) != (uiHelp>>16)) return 0;
	.symb	LINE, 588
	ld16.w	d15,[sp]8			; uiData
	mov.u	d7,#65535			; 65535
	and16	d15,d7
	ld.w	d7,[sp]12			; uiHelp
	sh	d7,d7,#-16
	jeq	d15,d7,_212
	mov16	d2,#0				; 0
	ret16
_212:
;  589 |	else uiData = *(puiAddress+1);
	.symb	LINE, 589
	nop
	ld.a	a7,[sp]4			; puiAddress
	ld.w	d15,[a7]4
	st16.w	[sp]8,d15			; uiData
;  590 |	uiHelp |= (uiData & 0xffff0000)>>16;
	.symb	LINE, 590
	ld16.w	d15,[sp]12			; uiHelp
	ld.w	d7,[sp]8			; uiData
	movh	d6,#0xffff			; -65536
	and16	d7,d6
	sh	d7,d7,#-16
	or16	d15,d7				; uiHelp
	st16.w	[sp]12,d15			; uiHelp
;  591 |	if ((uiData & 0xffff) != (uiHelp & 0xffff)) return 0;
	.symb	LINE, 591
	ld16.w	d15,[sp]8			; uiData
	mov.u	d7,#65535			; 65535
	and16	d15,d7
	ld.w	d7,[sp]12			; uiHelp
	mov.u	d6,#65535			; 65535
	and16	d7,d6
	jeq	d15,d7,_213
	mov16	d2,#0				; 0
	ret16
_213:
;  592 |
;  593 |	*puiAddress = AMDRESET;
	.symb	LINE, 593
	nop
	ld.a	a7,[sp]4			; puiAddress
	mov.u	d15,#0xf0			; 15728880
	addih	d15,d15,#0xf0			; 15728880
	st16.w	[a7],d15			; puiAddress
;  594 |	return uiHelp;
	.symb	LINE, 594
	ld.w	d2,[sp]12			; uiHelp
;  595 |}
	.symb	LINE, 595
_215:
	ret16
	.symb	EFUN
;  596 |
;  597 |/* Data Polling Algorithm for check command */
;  598 |unsigned int AMD_Data_Polling( unsigned int uiAddress, unsigned int uiValue )
;  599 |{	
	.symb	LINE, 599
	.symb	TYPE, 273, 'X', 8, #18, 26, 2, #18, #18
	.symb	GFUN, "AMD_Data_Polling", AMD_Data_Polling, #273, 0, 16, 0
	.symb	ALAB, AMD_Data_Polling, #273
AMD_Data_Polling:
	.symb	SOFF, 16
	.symb	LTIM, "uiAddress", 4, 0, 0x8cd
	.symb	LTIM, "uiValue", 5, 0, 0x8cd
	.symb	IDEN, "uiAddress", 4, #18, 0, 0x80d
	.symb	IDEN, "uiValue", 5, #18, 0, 0x80d
	.symb	IDEN, "uiData", -8, #18, 131, 0x5
	.symb	IDEN, "puiAddress", -4, #267, 131, 0x5
	.symb	LTIM, "uiValue", 5, 0, 0x84d
	.symb	LTIM, "uiValue", -16, 131, 0x8c5
	.symb	LTIM, "uiAddress", 4, 0, 0x84d
	.symb	LTIM, "uiAddress", -12, 131, 0x8c5
	.symb	LTIM, "uiAddress", -12, 131, 0x845
	.symb	LTIM, "uiAddress", 15, 0, 0x8cd
	nop
	sub16.a	sp,#16
;  600 |	register unsigned int uiData;
;  601 |	register unsigned int *puiAddress;
	.symb	LINE, 601
	st16.w	[sp],d5				; uiValue
	st.w	[sp]4,d4			; uiAddress
;  602 |	puiAddress = (unsigned int *)uiAddress;
	.symb	LINE, 602
	ld16.w	d15,[sp]4			; uiAddress
	mov16.a	a15,d15				; uiAddress
	st16.a	[sp]12,a15			; puiAddress
;  603 |	do
	.symb	LINE, 603
_216:
	.symb	LTIM, "uiAddress", 15, 0, 0x84d
	.symb	LTIM, "uiValue", -16, 131, 0x845
	.symb	LTIM, "uiValue", 7, 0, 0x8cd
	.symb	LTIM, "uiValue", 7, 0, 0x84d
;  604 |	{  	/* read value */
;  605 |	  	uiData = *puiAddress;
	.symb	LINE, 605
	nop
	ld.a	a7,[sp]12			; puiAddress
	ld16.w	d15,[a7]
	st16.w	[sp]8,d15			; uiData
;  606 |		/* check data ready */
;  607 |	   	if ((uiData & DQ7) == (uiValue & DQ7))
	.symb	LINE, 607
	ld16.w	d15,[sp]8			; uiData
	mov.u	d7,#0x80			; 8388736
	addih	d7,d7,#0x80			; 8388736
	and16	d15,d7
	ld16.w	d7,[sp]				; uiValue
	mov.u	d6,#0x80			; 8388736
	addih	d6,d6,#0x80			; 8388736
	and16	d7,d6
	jne	d15,d7,_217
;  608 |	   	{
;  609 |   	  	   *puiAddress = AMDRESET;
	.symb	LINE, 609
	ld.a	a7,[sp]12			; puiAddress
	mov.u	d15,#0xf0			; 15728880
	addih	d15,d15,#0xf0			; 15728880
	st16.w	[a7],d15			; puiAddress
;  610 |		   return SUCCESS;
	.symb	LINE, 610
	mov16	d2,#0				; 0
	ret16
;  611 |		}
	.symb	LINE, 611
_217:
	.symb	LTIM, "uiValue", 7, 0, 0x8cd
	.symb	LTIM, "uiValue", 7, 0, 0x84d
;  612 |		/* check of time out */
;  613 |		if ((uiData & DQ5) == DQ5)
	.symb	LINE, 613
	nop
	ld16.w	d15,[sp]8			; uiData
	mov.u	d7,#0x20			; 2097184
	addih	d7,d7,#0x20			; 2097184
	and16	d15,d7
	mov.u	d7,#0x20			; 2097184
	addih	d7,d7,#0x20			; 2097184
	jne	d15,d7,_219
;  614 |		{	uiData = *puiAddress;
	.symb	LINE, 614
	ld.a	a7,[sp]12			; puiAddress
	ld16.w	d15,[a7]
	st16.w	[sp]8,d15			; uiData
;  615 |		   	if ((uiData & DQ7) == (uiValue & DQ7))
	.symb	LINE, 615
	ld16.w	d15,[sp]8			; uiData
	mov.u	d7,#0x80			; 8388736
	addih	d7,d7,#0x80			; 8388736
	and16	d15,d7
	ld16.w	d7,[sp]				; uiValue
	mov.u	d6,#0x80			; 8388736
	addih	d6,d6,#0x80			; 8388736
	and16	d7,d6
	jne	d15,d7,_218
;  616 |   		   	{
;  617 |	   	  	   *puiAddress = AMDRESET;
	.symb	LINE, 617
	ld.a	a7,[sp]12			; puiAddress
	mov.u	d15,#0xf0			; 15728880
	addih	d15,d15,#0xf0			; 15728880
	st16.w	[a7],d15			; puiAddress
;  618 |			   return SUCCESS;
	.symb	LINE, 618
	mov16	d2,#0				; 0
	ret16
;  619 |			}
	.symb	LINE, 619
_218:
;  620 |			else
;  621 |		   	{
;  622 |	   	  	   *puiAddress = AMDRESET;
	.symb	LINE, 622
	nop
	ld.a	a7,[sp]12			; puiAddress
	mov.u	d15,#0xf0			; 15728880
	addih	d15,d15,#0xf0			; 15728880
	st16.w	[a7],d15			; puiAddress
;  623 |			   return FAILURE;
	.symb	LINE, 623
	mov16	d2,#1				; 1
	ret16
;  624 |			}
;  625 |		}
	.symb	LINE, 625
_219:
;  626 |	} while ((uiData & DQ5) != DQ5);
	.symb	LINE, 626
	nop
	ld16.w	d15,[sp]8			; uiData
	mov.u	d7,#0x20			; 2097184
	addih	d7,d7,#0x20			; 2097184
	and16	d15,d7
	mov.u	d7,#0x20			; 2097184
	addih	d7,d7,#0x20			; 2097184
	jne	d15,d7,_216
;  627 |
;  628 |return SUCCESS;
	.symb	LINE, 628
	mov16	d2,#0				; 0
;  629 |}
	.symb	LINE, 629
_222:
	ret16
	.symb	EFUN
;  630 |							   
;  631 |
;  632 |/* write value at address and wait for success */
;  633 |unsigned int AMD_Program_Word( unsigned int uiAddress, unsigned int uiValue, unsigned int uiFlashBase )
;  634 |{
	.symb	LINE, 634
	.symb	TYPE, 274, 'X', 8, #18, 26, 3, #18, #18, #18
	.symb	GFUN, "AMD_Program_Word", AMD_Program_Word, #274, 0, 16, 0
	.symb	ALAB, AMD_Program_Word, #274
AMD_Program_Word:
	.symb	SOFF, 16
	.symb	LTIM, "uiFlashBase", 6, 0, 0x8cd
	.symb	LTIM, "uiAddress", 4, 0, 0x8cd
	.symb	LTIM, "uiValue", 5, 0, 0x8cd
	.symb	IDEN, "uiAddress", 4, #18, 0, 0x80d
	.symb	IDEN, "uiValue", 5, #18, 0, 0x80d
	.symb	IDEN, "uiFlashBase", 6, #18, 0, 0x80d
	.symb	IDEN, "puiAddress", -4, #267, 131, 0x5
	.symb	LTIM, "uiFlashBase", 6, 0, 0x84d
	.symb	LTIM, "uiFlashBase", -16, 131, 0x8c5
	.symb	LTIM, "uiValue", 5, 0, 0x84d
	.symb	LTIM, "uiValue", -12, 131, 0x8c5
	.symb	LTIM, "uiAddress", 4, 0, 0x84d
	.symb	LTIM, "uiAddress", -8, 131, 0x8c5
	.symb	LTIM, "uiFlashBase", -16, 131, 0x845
	.symb	LTIM, "uiFlashBase", 15, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 15, 0, 0x84d
	.symb	LTIM, "uiFlashBase", 15, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 15, 0, 0x84d
	.symb	LTIM, "uiFlashBase", 15, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 15, 0, 0x84d
	.symb	LTIM, "uiAddress", -8, 131, 0x845
	.symb	LTIM, "uiAddress", 15, 0, 0x8cd
	.symb	LTIM, "uiAddress", 15, 0, 0x84d
	.symb	LTIM, "uiValue", -12, 131, 0x845
	.symb	LTIM, "uiValue", 15, 0, 0x8cd
	.symb	LTIM, "uiAddress", 4, 0, 0x8cd
	.symb	LTIM, "uiValue", 15, 0, 0x84d
	.symb	LTIM, "uiValue", 5, 0, 0x8cd
	.symb	LTIM, "uiAddress", 4, 0, 0x84d
	.symb	LTIM, "uiValue", 5, 0, 0x84d
	nop
	sub16.a	sp,#16
;  635 |	register unsigned int *puiAddress;
	.symb	LINE, 635
	st16.w	[sp],d6				; uiFlashBase
	st.w	[sp]4,d5			; uiValue
	st.w	[sp]8,d4			; uiAddress
;  636 |	/* first bus cycle */
;  637 |	puiAddress = (unsigned int *)(SETUP_ADDR+uiFlashBase);
	.symb	LINE, 637
	ld16.w	d15,[sp]			; uiFlashBase
	addi	d15,d15,#5460
	mov16.a	a15,d15
	st16.a	[sp]12,a15			; puiAddress
;  638 |	*puiAddress = AMDSETUP ;
	.symb	LINE, 638
	ld.a	a7,[sp]12			; puiAddress
	mov.u	d15,#0xaa			; 11141290
	addih	d15,d15,#0xaa			; 11141290
	st16.w	[a7],d15			; puiAddress
;  639 |	/* second bus cycle */
;  640 |	puiAddress = (unsigned int *)(UNLOCK_ADDR+uiFlashBase);
	.symb	LINE, 640
	ld16.w	d15,[sp]			; uiFlashBase
	addi	d15,d15,#2728
	mov16.a	a15,d15
	st16.a	[sp]12,a15			; puiAddress
;  641 |	*puiAddress = AMDUNLOCK;
	.symb	LINE, 641
	ld.a	a7,[sp]12			; puiAddress
	mov.u	d15,#0x55			; 5570645
	addih	d15,d15,#0x55			; 5570645
	st16.w	[a7],d15			; puiAddress
;  642 |	/* third bus cycle */
;  643 |	puiAddress = (unsigned int *)(SETUP_ADDR+uiFlashBase);
	.symb	LINE, 643
	ld16.w	d15,[sp]			; uiFlashBase
	addi	d15,d15,#5460
	mov16.a	a15,d15
	st16.a	[sp]12,a15			; puiAddress
;  644 |	*puiAddress = AMDPROGRAM;
	.symb	LINE, 644
	ld.a	a7,[sp]12			; puiAddress
	mov.u	d15,#0xa0			; 10485920
	addih	d15,d15,#0xa0			; 10485920
	st16.w	[a7],d15			; puiAddress
;  645 |	/* fourth bus cycle */
;  646 |	puiAddress = (unsigned int *)uiAddress;
	.symb	LINE, 646
	ld16.w	d15,[sp]8			; uiAddress
	mov16.a	a15,d15				; uiAddress
	st16.a	[sp]12,a15			; puiAddress
;  647 |	*puiAddress = uiValue;
	.symb	LINE, 647
	ld16.w	d15,[sp]4			; uiValue
	ld.a	a7,[sp]12			; puiAddress
	st16.w	[a7],d15			; puiAddress
;  648 |	/* data polling */
;  649 |	return AMD_Data_Polling( uiAddress, uiValue );
	.symb	LINE, 649
	ld.w	d4,[sp]8			; uiAddress
	ld.w	d5,[sp]4			; uiValue
	callg	AMD_Data_Polling
;  650 |}
	.symb	LINE, 650
_223:
	ret16
	.symb	EFUN
;  651 |
;  652 |/* chip erase */
;  653 |unsigned int AMD_Chip_Erase( unsigned int uiFlashBase )
;  654 |{
	.symb	LINE, 654
	.symb	TYPE, 275, 'X', 8, #18, 26, 1, #18
	.symb	GFUN, "AMD_Chip_Erase", AMD_Chip_Erase, #275, 0, 16, 0
	.symb	ALAB, AMD_Chip_Erase, #275
AMD_Chip_Erase:
	.symb	SOFF, 16
	.symb	LTIM, "uiFlashBase", 4, 0, 0x8cd
	.symb	IDEN, "uiFlashBase", 4, #18, 0, 0x80d
	.symb	IDEN, "puiAddress", -12, #267, 131, 0x5
	.symb	IDEN, "uiData", -8, #18, 131, 0x5
	.symb	LTIM, "uiFlashBase", 4, 0, 0x84d
	.symb	LTIM, "uiFlashBase", -16, 131, 0x8c5
	.symb	LTIM, "uiFlashBase", -16, 131, 0x845
	.symb	LTIM, "uiFlashBase", 15, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 15, 0, 0x84d
	.symb	LTIM, "uiFlashBase", 15, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 15, 0, 0x84d
	.symb	LTIM, "uiFlashBase", 15, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 15, 0, 0x84d
	.symb	LTIM, "uiFlashBase", 15, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 15, 0, 0x84d
	.symb	LTIM, "uiFlashBase", 15, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 15, 0, 0x84d
	.symb	LTIM, "uiFlashBase", 15, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 15, 0, 0x84d
	.symb	LTIM, "uiFlashBase", 15, 0, 0x8cd
	nop
	sub16.a	sp,#16
;  655 |	register unsigned int *puiAddress;
;  656 |	register unsigned int uiData = 0x0;
	.symb	LINE, 656
	st16.w	[sp],d4				; uiFlashBase
	mov16	d15,#0				; uiData
	st16.w	[sp]8,d15			; uiData
;  657 |	/* first bus cycle */
;  658 |	puiAddress = (unsigned int *)(SETUP_ADDR+uiFlashBase);
	.symb	LINE, 658
	ld16.w	d15,[sp]			; uiFlashBase
	addi	d15,d15,#5460
	mov16.a	a15,d15
	st16.a	[sp]4,a15			; puiAddress
;  659 |	*puiAddress = AMDSETUP;
	.symb	LINE, 659
	ld.a	a7,[sp]4			; puiAddress
	mov.u	d15,#0xaa			; 11141290
	addih	d15,d15,#0xaa			; 11141290
	st16.w	[a7],d15			; puiAddress
;  660 |	/* second bus cycle */
;  661 |	puiAddress = (unsigned int *)(UNLOCK_ADDR+uiFlashBase);
	.symb	LINE, 661
	ld16.w	d15,[sp]			; uiFlashBase
	addi	d15,d15,#2728
	mov16.a	a15,d15
	st16.a	[sp]4,a15			; puiAddress
;  662 |	*puiAddress = AMDUNLOCK;
	.symb	LINE, 662
	ld.a	a7,[sp]4			; puiAddress
	mov.u	d15,#0x55			; 5570645
	addih	d15,d15,#0x55			; 5570645
	st16.w	[a7],d15			; puiAddress
;  663 |	/* third bus cycle */
;  664 |	puiAddress = (unsigned int *)(SETUP_ADDR+uiFlashBase);
	.symb	LINE, 664
	ld16.w	d15,[sp]			; uiFlashBase
	addi	d15,d15,#5460
	mov16.a	a15,d15
	st16.a	[sp]4,a15			; puiAddress
;  665 |	*puiAddress = AMDCHIP_ERASE1;
	.symb	LINE, 665
	ld.a	a7,[sp]4			; puiAddress
	mov.u	d15,#0x80			; 8388736
	addih	d15,d15,#0x80			; 8388736
	st16.w	[a7],d15			; puiAddress
;  666 |	/* fourth bus cycle */
;  667 |	puiAddress = (unsigned int *)(SETUP_ADDR+uiFlashBase);
	.symb	LINE, 667
	ld16.w	d15,[sp]			; uiFlashBase
	addi	d15,d15,#5460
	mov16.a	a15,d15
	st16.a	[sp]4,a15			; puiAddress
;  668 |	*puiAddress = AMDSETUP;
	.symb	LINE, 668
	ld.a	a7,[sp]4			; puiAddress
	mov.u	d15,#0xaa			; 11141290
	addih	d15,d15,#0xaa			; 11141290
	st16.w	[a7],d15			; puiAddress
;  669 |	/* fifth bus cycle */
;  670 |	puiAddress = (unsigned int *)(UNLOCK_ADDR+uiFlashBase);
	.symb	LINE, 670
	ld16.w	d15,[sp]			; uiFlashBase
	addi	d15,d15,#2728
	mov16.a	a15,d15
	st16.a	[sp]4,a15			; puiAddress
;  671 |	*puiAddress = AMDUNLOCK;
	.symb	LINE, 671
	ld.a	a7,[sp]4			; puiAddress
	mov.u	d15,#0x55			; 5570645
	addih	d15,d15,#0x55			; 5570645
	st16.w	[a7],d15			; puiAddress
;  672 |	/* sixth bus cycle */
;  673 |	puiAddress = (unsigned int *)(SETUP_ADDR+uiFlashBase);
	.symb	LINE, 673
	ld16.w	d15,[sp]			; uiFlashBase
	addi	d15,d15,#5460
	mov16.a	a15,d15
	st16.a	[sp]4,a15			; puiAddress
;  674 |	*puiAddress = AMDCHIP_ERASE2;
	.symb	LINE, 674
	ld.a	a7,[sp]4			; puiAddress
	mov.u	d15,#0x10			; 1048592
	addih	d15,d15,#0x10			; 1048592
	st16.w	[a7],d15			; puiAddress
;  675 |	/* Polling while DQ7 == LOW */
;  676 |	puiAddress = (unsigned int *)uiFlashBase;
	.symb	LINE, 676
	ld16.w	d15,[sp]			; uiFlashBase
	mov16.a	a15,d15				; uiFlashBase
	st16.a	[sp]4,a15			; puiAddress
;  677 |	while ((uiData & DQ7) != DQ7) 
	.symb	LINE, 677
	j	_225
_224:
	.symb	LTIM, "uiFlashBase", 15, 0, 0x84d
;  678 |	{
;  679 |		uiData = *puiAddress;
	.symb	LINE, 679
	nop
	ld.a	a7,[sp]4			; puiAddress
	ld16.w	d15,[a7]
	st16.w	[sp]8,d15			; uiData
	.symb	LINE, 677
_225:
	nop
	ld16.w	d15,[sp]8			; uiData
	mov.u	d7,#0x80			; 8388736
	addih	d7,d7,#0x80			; 8388736
	and16	d15,d7
	mov.u	d7,#0x80			; 8388736
	addih	d7,d7,#0x80			; 8388736
	jne	d15,d7,_224
;  680 |	}
;  681 |
;  682 |	*puiAddress = AMDRESET;
	.symb	LINE, 682
	ld.a	a7,[sp]4			; puiAddress
	mov.u	d15,#0xf0			; 15728880
	addih	d15,d15,#0xf0			; 15728880
	st16.w	[a7],d15			; puiAddress
;  683 |	return SUCCESS;
	.symb	LINE, 683
	mov16	d2,#0				; 0
;  684 |}
	.symb	LINE, 684
_226:
	ret16
	.symb	EFUN
;  685 |
;  686 |/* sector erase */
;  687 |unsigned int AMD_Sector_Erase( unsigned int uiAddress, unsigned int uiFlashBase )
;  688 |{
	.symb	LINE, 688
	.symb	TYPE, 276, 'X', 8, #18, 26, 2, #18, #18
	.symb	GFUN, "AMD_Sector_Erase", AMD_Sector_Erase, #276, 0, 32, 0
	.symb	ALAB, AMD_Sector_Erase, #276
AMD_Sector_Erase:
	.symb	SOFF, 32
	.symb	LTIM, "uiFlashBase", 5, 0, 0x8cd
	.symb	LTIM, "uiAddress", 4, 0, 0x8cd
	.symb	IDEN, "uiAddress", 4, #18, 0, 0x80d
	.symb	IDEN, "uiFlashBase", 5, #18, 0, 0x80d
	.symb	IDEN, "puiAddress", -24, #267, 131, 0x5
	.symb	IDEN, "uiData", -20, #18, 131, 0x5
	.symb	LTIM, "uiFlashBase", 5, 0, 0x84d
	.symb	LTIM, "uiFlashBase", -32, 131, 0x8c5
	.symb	LTIM, "uiAddress", 4, 0, 0x84d
	.symb	LTIM, "uiAddress", -28, 131, 0x8c5
	.symb	IDEN, "puiSectorAddress", -16, #267, 131, 0x5
	.symb	LTIM, "uiAddress", -28, 131, 0x845
	.symb	LTIM, "uiAddress", 15, 0, 0x8cd
	.symb	LTIM, "uiAddress", 15, 0, 0x84d
	.symb	LTIM, "uiFlashBase", -32, 131, 0x845
	.symb	LTIM, "uiFlashBase", 15, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 15, 0, 0x84d
	.symb	LTIM, "uiFlashBase", 15, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 15, 0, 0x84d
	.symb	LTIM, "uiFlashBase", 15, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 15, 0, 0x84d
	.symb	LTIM, "uiFlashBase", 15, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 15, 0, 0x84d
	.symb	LTIM, "uiFlashBase", 15, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 15, 0, 0x84d
	nop
	sub16.a	sp,#32
;  689 |	register unsigned int *puiAddress;
;  690 |	register unsigned int uiData = 0x0;
	.symb	LINE, 690
	st16.w	[sp],d5				; uiFlashBase
	st.w	[sp]4,d4			; uiAddress
	mov16	d15,#0				; uiData
	st16.w	[sp]12,d15			; uiData
;  691 |	register unsigned int *puiSectorAddress;
;  692 |	puiSectorAddress = (unsigned int *)uiAddress;
	.symb	LINE, 692
	ld16.w	d15,[sp]4			; uiAddress
	mov16.a	a15,d15				; uiAddress
	st16.a	[sp]16,a15			; puiSectorAddress
;  693 |	/* first bus cycle */
;  694 |	puiAddress = (unsigned int *)(SETUP_ADDR+uiFlashBase);
	.symb	LINE, 694
	ld16.w	d15,[sp]			; uiFlashBase
	addi	d15,d15,#5460
	mov16.a	a15,d15
	st16.a	[sp]8,a15			; puiAddress
;  695 |	*puiAddress = AMDSETUP;
	.symb	LINE, 695
	ld.a	a7,[sp]8			; puiAddress
	mov.u	d15,#0xaa			; 11141290
	addih	d15,d15,#0xaa			; 11141290
	st16.w	[a7],d15			; puiAddress
;  696 |	/* second bus cycle */
;  697 |	puiAddress = (unsigned int *)(UNLOCK_ADDR+uiFlashBase);
	.symb	LINE, 697
	ld16.w	d15,[sp]			; uiFlashBase
	addi	d15,d15,#2728
	mov16.a	a15,d15
	st16.a	[sp]8,a15			; puiAddress
;  698 |	*puiAddress = AMDUNLOCK;
	.symb	LINE, 698
	ld.a	a7,[sp]8			; puiAddress
	mov.u	d15,#0x55			; 5570645
	addih	d15,d15,#0x55			; 5570645
	st16.w	[a7],d15			; puiAddress
;  699 |	/* third bus cycle */
;  700 |	puiAddress = (unsigned int *)(SETUP_ADDR+uiFlashBase);
	.symb	LINE, 700
	ld16.w	d15,[sp]			; uiFlashBase
	addi	d15,d15,#5460
	mov16.a	a15,d15
	st16.a	[sp]8,a15			; puiAddress
;  701 |	*puiAddress = AMDCHIP_ERASE1;
	.symb	LINE, 701
	ld.a	a7,[sp]8			; puiAddress
	mov.u	d15,#0x80			; 8388736
	addih	d15,d15,#0x80			; 8388736
	st16.w	[a7],d15			; puiAddress
;  702 |	/* fourth bus cycle */
;  703 |	puiAddress = (unsigned int *)(SETUP_ADDR+uiFlashBase);
	.symb	LINE, 703
	ld16.w	d15,[sp]			; uiFlashBase
	addi	d15,d15,#5460
	mov16.a	a15,d15
	st16.a	[sp]8,a15			; puiAddress
;  704 |	*puiAddress = AMDSETUP;
	.symb	LINE, 704
	ld.a	a7,[sp]8			; puiAddress
	mov.u	d15,#0xaa			; 11141290
	addih	d15,d15,#0xaa			; 11141290
	st16.w	[a7],d15			; puiAddress
;  705 |	/* fifth bus cycle */
;  706 |	puiAddress = (unsigned int *)(UNLOCK_ADDR+uiFlashBase);
	.symb	LINE, 706
	ld16.w	d15,[sp]			; uiFlashBase
	addi	d15,d15,#2728
	mov16.a	a15,d15
	st16.a	[sp]8,a15			; puiAddress
;  707 |	*puiAddress = AMDUNLOCK;
	.symb	LINE, 707
	ld.a	a7,[sp]8			; puiAddress
	mov.u	d15,#0x55			; 5570645
	addih	d15,d15,#0x55			; 5570645
	st16.w	[a7],d15			; puiAddress
;  708 |	/* sixth bus cycle */
;  709 |	puiAddress = (unsigned int *)puiSectorAddress;
	.symb	LINE, 709
	ld.a	a7,[sp]16			; puiSectorAddress
	st.a	[sp]8,a7			; puiAddress
;  710 |	*puiAddress = AMDSECTOR_ERASE;
	.symb	LINE, 710
	ld.a	a7,[sp]8			; puiAddress
	mov.u	d15,#0x30			; 3145776
	addih	d15,d15,#0x30			; 3145776
	st16.w	[a7],d15			; puiAddress
;  711 |	/* Polling while DQ7 == LOW */
;  712 |	while ( (uiData & DQ7) != DQ7 )	uiData = *puiSectorAddress;
	.symb	LINE, 712
	j	_228
_227:
	nop
	ld.a	a7,[sp]16			; puiSectorAddress
	ld16.w	d15,[a7]
	st16.w	[sp]12,d15			; uiData
_228:
	nop
	ld16.w	d15,[sp]12			; uiData
	mov.u	d7,#0x80			; 8388736
	addih	d7,d7,#0x80			; 8388736
	and16	d15,d7
	mov.u	d7,#0x80			; 8388736
	addih	d7,d7,#0x80			; 8388736
	jne	d15,d7,_227
;  713 |	return SUCCESS;
	.symb	LINE, 713
	mov16	d2,#0				; 0
;  714 |}
	.symb	LINE, 714
_229:
	ret16
	.symb	EFUN
;  715 |
;  716 |unsigned int Intel_Flash_ID( unsigned int uiFlashBase )
;  717 |{
	.symb	LINE, 717
	.symb	TYPE, 277, 'X', 8, #18, 26, 1, #18
	.symb	GFUN, "Intel_Flash_ID", Intel_Flash_ID, #277, 0, 16, 0
	.symb	ALAB, Intel_Flash_ID, #277
Intel_Flash_ID:
	.symb	SOFF, 16
	.symb	LTIM, "uiFlashBase", 4, 0, 0x8cd
	.symb	IDEN, "uiFlashBase", 4, #18, 0, 0x80d
	.symb	IDEN, "puiAddress", -12, #267, 131, 0x5
	.symb	IDEN, "uiData", -8, #18, 131, 0x5
	.symb	LTIM, "uiFlashBase", 4, 0, 0x84d
	.symb	LTIM, "uiFlashBase", -16, 131, 0x8c5
	.symb	IDEN, "uiHelp", -4, #18, 131, 0x5
	.symb	LTIM, "uiFlashBase", -16, 131, 0x845
	.symb	LTIM, "uiFlashBase", 15, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 15, 0, 0x84d
	nop
	sub16.a	sp,#16
;  718 |	volatile unsigned int *puiAddress;
;  719 |	unsigned int uiData = 0x0;
	.symb	LINE, 719
	st16.w	[sp],d4				; uiFlashBase
	mov16	d15,#0				; uiData
	st16.w	[sp]8,d15			; uiData
;  720 |	unsigned int uiHelp = 0x0;
	.symb	LINE, 720
	mov16	d15,#0				; uiHelp
	st16.w	[sp]12,d15			; uiHelp
;  721 |
;  722 |	/* first bus cycle */
;  723 |	puiAddress = (unsigned int *)(uiFlashBase);
	.symb	LINE, 723
	ld16.w	d15,[sp]			; uiFlashBase
	mov16.a	a15,d15				; uiFlashBase
	st16.a	[sp]4,a15			; puiAddress
;  724 |	*puiAddress = INTELREAD_ID;
	.symb	LINE, 724
	ld.a	a7,[sp]4			; puiAddress
	mov.u	d15,#0x90			; 9437328
	addih	d15,d15,#0x90			; 9437328
	st16.w	[a7],d15			; puiAddress
;  725 |
;  726 |	uiData = *puiAddress;
	.symb	LINE, 726
	ld.a	a7,[sp]4			; puiAddress
	ld16.w	d15,[a7]
	st16.w	[sp]8,d15			; uiData
;  727 |	uiHelp = (uiData & 0xffff0000);
	.symb	LINE, 727
	ld16.w	d15,[sp]8			; uiData
	movh	d7,#0xffff			; -65536
	and16	d15,d7
	st16.w	[sp]12,d15			; uiHelp
;  728 |	if ((uiData & 0xffff) != (uiHelp>>16)) return 0;
	.symb	LINE, 728
	ld16.w	d15,[sp]8			; uiData
	mov.u	d7,#65535			; 65535
	and16	d15,d7
	ld.w	d7,[sp]12			; uiHelp
	sh	d7,d7,#-16
	jeq	d15,d7,_230
	mov16	d2,#0				; 0
	ret16
_230:
;  729 |	else uiData = *(puiAddress+1);
	.symb	LINE, 729
	nop
	ld.a	a7,[sp]4			; puiAddress
	ld.w	d15,[a7]4
	st16.w	[sp]8,d15			; uiData
;  730 |	uiHelp |= (uiData & 0xffff0000)>>16;
	.symb	LINE, 730
	ld16.w	d15,[sp]12			; uiHelp
	ld.w	d7,[sp]8			; uiData
	movh	d6,#0xffff			; -65536
	and16	d7,d6
	sh	d7,d7,#-16
	or16	d15,d7				; uiHelp
	st16.w	[sp]12,d15			; uiHelp
;  731 |	if ((uiData & 0xffff) != (uiHelp & 0xffff)) return 0;
	.symb	LINE, 731
	ld16.w	d15,[sp]8			; uiData
	mov.u	d7,#65535			; 65535
	and16	d15,d7
	ld.w	d7,[sp]12			; uiHelp
	mov.u	d6,#65535			; 65535
	and16	d7,d6
	jeq	d15,d7,_231
	mov16	d2,#0				; 0
	ret16
_231:
;  732 |
;  733 |	*puiAddress = INTELREAD_ARRAY;
	.symb	LINE, 733
	nop
	ld.a	a7,[sp]4			; puiAddress
	mov.u	d15,#0xff			; 16711935
	addih	d15,d15,#0xff			; 16711935
	st16.w	[a7],d15			; puiAddress
;  734 |
;  735 |	return uiHelp;
	.symb	LINE, 735
	ld.w	d2,[sp]12			; uiHelp
;  736 |}
	.symb	LINE, 736
_233:
	ret16
	.symb	EFUN
;  737 |
;  738 |unsigned int Intel_Chip_Erase(unsigned int uiID, unsigned int uiFlashBase)
;  739 |{
	.symb	LINE, 739
	.symb	TYPE, 278, 'X', 8, #18, 26, 2, #18, #18
	.symb	GFUN, "Intel_Chip_Erase", Intel_Chip_Erase, #278, 0, 32, 0
	.symb	ALAB, Intel_Chip_Erase, #278
Intel_Chip_Erase:
	.symb	SOFF, 32
	.symb	LTIM, "uiID", 4, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 5, 0, 0x8cd
	.symb	IDEN, "uiID", 4, #18, 0, 0x80d
	.symb	IDEN, "uiFlashBase", 5, #18, 0, 0x80d
	.symb	IDEN, "puiAddress", -24, #267, 131, 0x5
	.symb	IDEN, "uiCnt", -20, #18, 131, 0x5
	.symb	IDEN, "uiSectorNumbers", -16, #18, 131, 0x5
	.symb	IDEN, "uiTop", -12, #18, 131, 0x5
	.symb	IDEN, "uiStatus", -8, #18, 131, 0x5
	.symb	LTIM, "uiFlashBase", 5, 0, 0x84d
	.symb	LTIM, "uiFlashBase", -32, 131, 0x8c5
	.symb	LTIM, "uiID", 4, 0, 0x84d
	.symb	LTIM, "uiID", -28, 131, 0x8c5
	.symb	LTIM, "uiID", -28, 131, 0x845
	.symb	LTIM, "uiID", 15, 0, 0x8cd
	.symb	LTIM, "uiID", 15, 0, 0x84d
	nop
	sub16.a	sp,#32
;  740 |	volatile unsigned int *puiAddress;
;  741 |	unsigned int uiCnt, uiSectorNumbers, uiTop;
;  742 |	unsigned int uiStatus;
	.symb	LINE, 742
	st16.w	[sp],d5				; uiFlashBase
	st.w	[sp]4,d4			; uiID
;  743 |
;  744 |	uiTop = 0;
	.symb	LINE, 744
	mov16	d15,#0				; uiTop
	st16.w	[sp]20,d15			; uiTop
;  745 |
;  746 |	switch(uiID & 0xFFFF)
	.symb	LINE, 746
	ld16.w	d15,[sp]4			; uiID
	mov.u	d7,#65535			; 65535
	and16	d15,d7
	addih	d15,d15,#65535
	addi	d15,d15,#30476
	jeq	d15,#-3,_234			; case 35057
	jeq	d15,#-2,_235			; case 35058
	jeq	d15,#-1,_236			; case 35059
	jeq	d15,#0,_237			; case 35060
	j	_238				; default
;  747 |	{
;  748 |		case DT28F800F3T_ID: uiTop = 1;
	.symb	LINE, 748
_234:
	mov16	d15,#1				; uiTop
	st16.w	[sp]20,d15			; uiTop
;  749 |		case DT28F800F3B_ID: uiSectorNumbers = 23;
	.symb	LINE, 749
_235:
	mov16	d15,#23				; uiSectorNumbers
	st16.w	[sp]16,d15			; uiSectorNumbers
;  750 |				     break;
	.symb	LINE, 750
	j	_240
;  751 |		case DT28F160F3T_ID: uiTop = 1;
	.symb	LINE, 751
_236:
	mov16	d15,#1				; uiTop
	st16.w	[sp]20,d15			; uiTop
;  752 |		case DT28F160F3B_ID: uiSectorNumbers = 39;
	.symb	LINE, 752
_237:
	mov16	d15,#39				; uiSectorNumbers
	st16.w	[sp]16,d15			; uiSectorNumbers
;  753 |				     break;
	.symb	LINE, 753
	j	_240
;  754 |		default:	     return 1;
	.symb	LINE, 754
_238:
	mov16	d2,#1				; 1
	ret16
;  755 |	}
	.symb	LINE, 755
_240:
	.symb	LTIM, "uiFlashBase", -32, 131, 0x845
	.symb	LTIM, "uiFlashBase", 15, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 15, 0, 0x84d
;  756 |
;  757 |	puiAddress = (unsigned int *)(uiFlashBase);
	.symb	LINE, 757
	nop
	ld16.w	d15,[sp]			; uiFlashBase
	mov16.a	a15,d15				; uiFlashBase
	st16.a	[sp]8,a15			; puiAddress
;  758 |
;  759 |	for (uiCnt=0; uiCnt<uiSectorNumbers; uiCnt++)
	.symb	LINE, 759
	mov16	d15,#0				; uiCnt
	st16.w	[sp]12,d15			; uiCnt
	j	_250
_241:
;  760 |	{
;  761 |
;  762 |		*puiAddress = INTELBLK_ERASE;
	.symb	LINE, 762
	nop
	ld.a	a7,[sp]8			; puiAddress
	mov.u	d15,#0x20			; 2097184
	addih	d15,d15,#0x20			; 2097184
	st16.w	[a7],d15			; puiAddress
;  763 |		*puiAddress = INTELRESUME;
	.symb	LINE, 763
	ld.a	a7,[sp]8			; puiAddress
	mov.u	d15,#0xd0			; 13631696
	addih	d15,d15,#0xd0			; 13631696
	st16.w	[a7],d15			; puiAddress
;  764 |		do
	.symb	LINE, 764
_242:
;  765 |		{
;  766 |			uiStatus = *puiAddress;
	.symb	LINE, 766
	nop
	ld.a	a7,[sp]8			; puiAddress
	ld16.w	d15,[a7]
	st16.w	[sp]24,d15			; uiStatus
;  767 |		} while ((uiStatus & STAT_WSMS) != STAT_WSMS);
	.symb	LINE, 767
	ld16.w	d15,[sp]24			; uiStatus
	mov.u	d7,#0x80			; 8388736
	addih	d7,d7,#0x80			; 8388736
	and16	d15,d7
	mov.u	d7,#0x80			; 8388736
	addih	d7,d7,#0x80			; 8388736
	jne	d15,d7,_242
;  768 |		if (uiStatus & STAT_ES) return FAILURE;
	.symb	LINE, 768
	ld16.w	d15,[sp]24			; uiStatus
	mov.u	d7,#0x20			; 2097184
	addih	d7,d7,#0x20			; 2097184
	and16	d15,d7
	jeq	d15,#0,_243
	mov16	d2,#1				; 1
	ret16
_243:
;  769 |		if (uiTop)
	.symb	LINE, 769
	nop
	ld16.w	d15,[sp]20			; uiTop
	jeq	d15,#0,_246			; uiTop
;  770 |		{
;  771 |			if (uiCnt<(uiSectorNumbers-8)) puiAddress += 0x2000;
	.symb	LINE, 771
	ld16.w	d15,[sp]12			; uiCnt
	ld.w	d7,[sp]16			; uiSectorNumbers
	add16	d7,#-8
	jge.u	d15,d7,_244
	ld.a	a7,[sp]8			; puiAddress
	mov.u	d15,#32768			; 32768
	addsc.a	a7,a7,d15,#0			; puiAddress
	st.a	[sp]8,a7			; puiAddress
	j	_245
_244:
;  772 |			else puiAddress += 0x400;
	.symb	LINE, 772
	nop
	ld.a	a7,[sp]8			; puiAddress
	lea	a7,[a7]4096			; puiAddress
	st.a	[sp]8,a7			; puiAddress
_245:
;  773 |		}
	.symb	LINE, 773
	j	_249
_246:
;  774 |		else
;  775 |		{
;  776 |			if (uiCnt<8) puiAddress += 0x400;
	.symb	LINE, 776
	nop
	ld16.w	d15,[sp]12			; uiCnt
	jge.u	d15,#8,_247
	ld.a	a7,[sp]8			; puiAddress
	lea	a7,[a7]4096			; puiAddress
	st.a	[sp]8,a7			; puiAddress
	j	_248
_247:
;  777 |			else puiAddress += 0x2000;
	.symb	LINE, 777
	nop
	ld.a	a7,[sp]8			; puiAddress
	mov.u	d15,#32768			; 32768
	addsc.a	a7,a7,d15,#0			; puiAddress
	st.a	[sp]8,a7			; puiAddress
_248:
;  778 |		}
	.symb	LINE, 778
_249:
	.symb	LINE, 759
	nop
	ld16.w	d15,[sp]12			; uiCnt
	add16	d15,#1				; uiCnt
	st16.w	[sp]12,d15			; uiCnt
_250:
	nop
	ld16.w	d15,[sp]12			; uiCnt
	ld.w	d7,[sp]16			; uiSectorNumbers
	jlt.u	d15,d7,_241
;  779 |	}
;  780 |	*puiAddress = INTELREAD_ARRAY;
	.symb	LINE, 780
	ld.a	a7,[sp]8			; puiAddress
	mov.u	d15,#0xff			; 16711935
	addih	d15,d15,#0xff			; 16711935
	st16.w	[a7],d15			; puiAddress
;  781 |
;  782 |	return SUCCESS;
	.symb	LINE, 782
	mov16	d2,#0				; 0
;  783 |}
	.symb	LINE, 783
_252:
	ret16
	.symb	EFUN
;  784 |
;  785 |unsigned int Intel_Program_Word( unsigned int uiAddress, unsigned int uiValue )
;  786 |{
	.symb	LINE, 786
	.symb	TYPE, 279, 'X', 8, #18, 26, 2, #18, #18
	.symb	GFUN, "Intel_Program_Word", Intel_Program_Word, #279, 0, 16, 0
	.symb	ALAB, Intel_Program_Word, #279
Intel_Program_Word:
	.symb	SOFF, 16
	.symb	LTIM, "uiAddress", 4, 0, 0x8cd
	.symb	LTIM, "uiValue", 5, 0, 0x8cd
	.symb	IDEN, "uiAddress", 4, #18, 0, 0x80d
	.symb	IDEN, "uiValue", 5, #18, 0, 0x80d
	.symb	IDEN, "puiAddress", -8, #267, 131, 0x5
	.symb	IDEN, "uiStatus", -4, #18, 131, 0x5
	.symb	LTIM, "uiValue", 5, 0, 0x84d
	.symb	LTIM, "uiValue", -16, 131, 0x8c5
	.symb	LTIM, "uiAddress", 4, 0, 0x84d
	.symb	LTIM, "uiAddress", -12, 131, 0x8c5
	.symb	LTIM, "uiAddress", -12, 131, 0x845
	.symb	LTIM, "uiAddress", 15, 0, 0x8cd
	.symb	LTIM, "uiAddress", 15, 0, 0x84d
	.symb	LTIM, "uiValue", -16, 131, 0x845
	.symb	LTIM, "uiValue", 15, 0, 0x8cd
	nop
	sub16.a	sp,#16
;  787 |	volatile unsigned int *puiAddress;
;  788 |	unsigned int uiStatus;
	.symb	LINE, 788
	st16.w	[sp],d5				; uiValue
	st.w	[sp]4,d4			; uiAddress
;  789 |
;  790 |	puiAddress = (unsigned int *)(uiAddress);
	.symb	LINE, 790
	ld16.w	d15,[sp]4			; uiAddress
	mov16.a	a15,d15				; uiAddress
	st16.a	[sp]8,a15			; puiAddress
;  791 |
;  792 |	*puiAddress = INTELPROG_STD;
	.symb	LINE, 792
	ld.a	a7,[sp]8			; puiAddress
	mov.u	d15,#0x40			; 4194368
	addih	d15,d15,#0x40			; 4194368
	st16.w	[a7],d15			; puiAddress
;  793 |	*puiAddress = uiValue;
	.symb	LINE, 793
	ld16.w	d15,[sp]			; uiValue
	ld.a	a7,[sp]8			; puiAddress
	st16.w	[a7],d15			; puiAddress
;  794 |	do
	.symb	LINE, 794
_253:
	.symb	LTIM, "uiValue", 15, 0, 0x84d
	.symb	LTIM, "uiValue", 15, 0, 0x8cd
;  795 |	{
;  796 |		uiStatus = *puiAddress;
	.symb	LINE, 796
	nop
	ld.a	a7,[sp]8			; puiAddress
	ld16.w	d15,[a7]
	st16.w	[sp]12,d15			; uiStatus
;  797 |	} while ((uiStatus & STAT_WSMS) != STAT_WSMS);
	.symb	LINE, 797
	ld16.w	d15,[sp]12			; uiStatus
	mov.u	d7,#0x80			; 8388736
	addih	d7,d7,#0x80			; 8388736
	and16	d15,d7
	mov.u	d7,#0x80			; 8388736
	addih	d7,d7,#0x80			; 8388736
	jne	d15,d7,_253
;  798 |
;  799 |	if (uiStatus & STAT_PS)
	.symb	LINE, 799
	ld16.w	d15,[sp]12			; uiStatus
	mov.u	d7,#0x10			; 1048592
	addih	d7,d7,#0x10			; 1048592
	and16	d15,d7
	jeq	d15,#0,_256
;  800 |	{
;  801 |		*puiAddress = INTELPROG_ALT;
	.symb	LINE, 801
	ld.a	a7,[sp]8			; puiAddress
	mov.u	d15,#0x10			; 1048592
	addih	d15,d15,#0x10			; 1048592
	st16.w	[a7],d15			; puiAddress
;  802 |		*puiAddress = uiValue;
	.symb	LINE, 802
	ld16.w	d15,[sp]			; uiValue
	ld.a	a7,[sp]8			; puiAddress
	st16.w	[a7],d15			; puiAddress
;  803 |		do
	.symb	LINE, 803
_254:
	.symb	LTIM, "uiValue", 15, 0, 0x84d
;  804 |		{
;  805 |			uiStatus = *puiAddress;
	.symb	LINE, 805
	nop
	ld.a	a7,[sp]8			; puiAddress
	ld16.w	d15,[a7]
	st16.w	[sp]12,d15			; uiStatus
;  806 |		} while ((uiStatus & STAT_WSMS) != STAT_WSMS);
	.symb	LINE, 806
	ld16.w	d15,[sp]12			; uiStatus
	mov.u	d7,#0x80			; 8388736
	addih	d7,d7,#0x80			; 8388736
	and16	d15,d7
	mov.u	d7,#0x80			; 8388736
	addih	d7,d7,#0x80			; 8388736
	jne	d15,d7,_254
;  807 |
;  808 |		if (uiStatus & STAT_PS) return FAILURE;
	.symb	LINE, 808
	ld16.w	d15,[sp]12			; uiStatus
	mov.u	d7,#0x10			; 1048592
	addih	d7,d7,#0x10			; 1048592
	and16	d15,d7
	jeq	d15,#0,_255
	mov16	d2,#1				; 1
	ret16
_255:
;  809 |	}
	.symb	LINE, 809
_256:
;  810 |	*puiAddress = INTELREAD_ARRAY;
	.symb	LINE, 810
	nop
	ld.a	a7,[sp]8			; puiAddress
	mov.u	d15,#0xff			; 16711935
	addih	d15,d15,#0xff			; 16711935
	st16.w	[a7],d15			; puiAddress
;  811 |
;  812 |	return SUCCESS;
	.symb	LINE, 812
	mov16	d2,#0				; 0
;  813 |}
	.symb	LINE, 813
_257:
	ret16
	.symb	EFUN
	.symb	ENDF
	.sdecl	"fardata.flash_test",DATA,INIT
	.sect	"fardata.flash_test"
	.align	4
_22:
	.ascii	"	Flash = TC58FVB400FT"
	.byte	0x0a,0x00
	.align	2
_30:
	.ascii	"	Flash name = DT28F800F3T"
	.byte	0x0a,0x00
	.align	2
_17:
	.ascii	"Testing FLASH at /CS0..."
	.byte	0x0a,0x00
_48:
	.ascii	"	Programming testpattern..."
	.byte	0x0a,0x00
	.align	2
_20:
	.ascii	"	Flash = AM29LV200BB"
	.byte	0x0a,0x00
_39:
	.ascii	"	Flash name = MBM29DL323TE"
	.byte	0x0a,0x00
_45:
	.ascii	"	Datalines are O.K. "
	.byte	0x0a,0x00
_38:
	.ascii	"	Flash name = DT28F160F3T"
	.byte	0x0a,0x00
	.align	2
_27:
	.ascii	"	Flash name = AM29LV800TB"
	.byte	0x0a,0x00
	.align	2
_29:
	.ascii	"	Flash name = AM29BL802C"
	.byte	0x0a,0x00
_49:
	.ascii	"	Reading testpattern..."
	.byte	0x0a,0x00
	.align	2
_46:
	.ascii	"	Erasing Flash for addressline test. This takes a while..."
	.byte	0x0a,0x00
_31:
	.ascii	"	Flash name = DT28F800F3B"
	.byte	0x0a,0x00
	.align	2
_36:
	.ascii	"	Flash name = AM29BL162C"
	.byte	0x0a,0x00
_47:
	.ascii	"ERROR: Failed to erase Flash!!!"
	.byte	0x00
_23:
	.ascii	"	Flash name = AM29LV400TB"
	.byte	0x0a,0x00
	.align	2
_43:
	.ascii	"	ERROR erasing sector! "
	.byte	0x0a,0x00
	.align	2
_26:
	.ascii	"	Flash name = TC58FVB800FT"
	.byte	0x0a,0x00
	.symb	TYPE, 280, 'X', 8, #16, 26, 2, #258, #1
	.symb	ALAB, printf, #280
_37:
	.ascii	"	Flash name = DT28F160F3B"
	.byte	0x0a,0x00
	.align	2
_44:
	.ascii	"	FLASH-BANK1 ERROR: DATA read=%08x at addr.=%08x check=%08x"
	.ascii	" "
	.byte	0x0a,0x00
_128:
	.ascii	"	FLASH-BANK_2 O.K. "
	.byte	0x0a,0x00
	.align	2
_34:
	.ascii	"	Flash name = AM29LV160TB"
	.byte	0x0a,0x00
	.align	2
_125:
	.ascii	"Testing FLASH at /CS3..."
	.byte	0x0a,0x00
_40:
	.ascii	"	Flash nicht bekannt!"
	.byte	0x0a,0x00
	.align	2
_24:
	.ascii	"	Flash name = AM29LV400BB"
	.byte	0x0a,0x00
	.align	2
_41:
	.ascii	"	Sector erase not yet implemented for Intel Flashes. Skippi"
	.ascii	"ng Flash-Dataline Test"
	.byte	0x00
_51:
	.ascii	"	FLASH-BANK_1 O.K. "
	.byte	0x0a,0x00
	.align	2
_25:
	.ascii	"	Flash name = TC58FVT800FT"
	.byte	0x0a,0x00
_21:
	.ascii	"	Flash = TC58FVT400FT"
	.byte	0x0a,0x00
	.align	2
_50:
	.ascii	"	FLASH-BANK1 ERROR: data read=%08x at ADDR.=%08x check=%08x"
	.ascii	" "
	.byte	0x0a,0x00
_28:
	.ascii	"	Flash name = AM29LV800BB"
	.byte	0x0a,0x00
	.align	2
_18:
	.ascii	"	Unknown Manufacturer ID [%X]"
	.byte	0x0a,0x00
	.align	2
_32:
	.ascii	"	Flash name = TC58FVT160FT"
	.byte	0x0a,0x00
_126:
	.ascii	"	FLASH-BANK2 ERROR: DATA read=%08x at addr.=%08x check=%08x"
	.ascii	" "
	.byte	0x0a,0x00
_127:
	.ascii	"	FLASH-BANK2 ERROR: data read=%08x at ADDR.=%08x check=%08x"
	.ascii	" "
	.byte	0x0a,0x00
_35:
	.ascii	"	Flash name = AM29LV160BB"
	.byte	0x0a,0x00
	.align	2
_42:
	.ascii	"	Erasing sector 0 of Flash for dataline test..."
	.byte	0x0a,0x00
	.align	2
_33:
	.ascii	"	Flash name = TC58FVB160FT"
	.byte	0x0a,0x00
_19:
	.ascii	"	Flash name = AM29LV200TB"
	.byte	0x0a,0x00
	.align	4
	.global	AMD_Chip_Erase
	.global	AMD_Data_Polling
	.global	AMD_Flash_ID
	.global	AMD_Program_Word
	.global	AMD_Sector_Erase
	.global	Chip_Erase
	.global	FLASH_TEST_BANK1
	.global	FLASH_TEST_BANK2
	.global	Intel_Chip_Erase
	.global	Intel_Flash_ID
	.global	Intel_Program_Word
	.global	Program_Word
	.global	Read_ID
	.extern	(CODE) printf
	.calls	"AMD_Program_Word", "AMD_Data_Polling"
	.calls	"Chip_Erase", "AMD_Chip_Erase"
	.calls	"Chip_Erase", "Intel_Chip_Erase"
	.calls	"FLASH_TEST_BANK1", "AMD_Sector_Erase"
	.calls	"FLASH_TEST_BANK1", "Chip_Erase"
	.calls	"FLASH_TEST_BANK1", "Program_Word"
	.calls	"FLASH_TEST_BANK1", "Read_ID"
	.calls	"FLASH_TEST_BANK1", "printf"
	.calls	"FLASH_TEST_BANK2", "AMD_Sector_Erase"
	.calls	"FLASH_TEST_BANK2", "Chip_Erase"
	.calls	"FLASH_TEST_BANK2", "Program_Word"
	.calls	"FLASH_TEST_BANK2", "Read_ID"
	.calls	"FLASH_TEST_BANK2", "printf"
	.calls	"Program_Word", "AMD_Program_Word"
	.calls	"Program_Word", "Intel_Program_Word"
	.calls	"Read_ID", "AMD_Flash_ID"
	.calls	"Read_ID", "Intel_Flash_ID"
