; TASKING TriCore C compiler v1.5r1 Build 322 SN 00090364
; options: -e -A1 -g -O1 -Id:\ctri\include -s -N8 -zTC112_COR1 -zTC112_COR4
;          -zTC112_COR10 -zTC112_COR13 -zTC112_COR14 -zTC112_COR16 -zTC112_COR17
	.name	"flash"
	.symb	TOOL, "TASKING TriCore C compiler v1.5", 1
	.symb	TYPE, 256, "bit", 'g', 0, 1
	.symb	FILE, "flash.c"
; file "flash.c":
;    1 |/****************************************************************************
;    2 |       Module: FLASH.C
;    3 |  Description: This source code is based on example code written by Holger
;    4 |               Dienst of Infineon
;    5 |Version     Date           Initials    Description
;    6 |1.0.0       26.02.1999     HD          Initial
;    7 |1.0.1       06.06.2000     MH          Added code to automatically check size
;    8 |                                       of external SRAM (previously assumed
;    9 |                                       size was 1MB)
;   10 |****************************************************************************/
;   11 |#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
;   12 |#include <string.h>
	.symb	FILE, "d:\\ctri\\include\\string.h"
	.symb	ENDF
;   13 |
;   14 |unsigned int Read_ID( unsigned int uiFlashBase );
;   15 |unsigned int Chip_Erase(unsigned int uiID, unsigned int uiFlashBase);
;   16 |unsigned int Program_Word(unsigned int uiID, unsigned int uiAddress, unsigned int uiValue, unsigned int uiFlashBase );
;   17 |unsigned int Intel_Flash_ID( unsigned int uiFlashBase );
;   18 |unsigned int Intel_Chip_Erase(unsigned int uiID, unsigned int uiFlashBase);
;   19 |unsigned int Intel_Program_Word( unsigned int uiAddress, unsigned int uiValue );
;   20 |unsigned int AMD_Flash_ID( unsigned int uiFlashBase );
;   21 |unsigned int AMD_Chip_Erase( unsigned int uiFlashBase );
;   22 |unsigned int AMD_Program_Word( unsigned int uiAddress, unsigned int uiValue, unsigned int uiFlashBase );
;   23 |
;   24 |/* Config address */
;   25 |#define   SETUP_ADDR      0x1554
;   26 |#define UNLOCK_ADDR      0xAA8
;   27 |
;   28 |/* AMD Flash commands */
;   29 |#define   AMDSETUP        0x00AA00AA
;   30 |#define   AMDUNLOCK        0x00550055
;   31 |#define   AMDREAD_ID       0x00900090
;   32 |#define   AMDPROGRAM       0x00A000A0
;   33 |#define   AMDCHIP_ERASE1   0x00800080
;   34 |#define   AMDCHIP_ERASE2   0x00100010
;   35 |#define   AMDSECTOR_ERASE   0x00300030
;   36 |#define   AMDRESET          0x00F000F0
;   37 |
;   38 |/* INTEL Flash commands */
;   39 |#define   INTELREAD_ID      0x00900090
;   40 |#define   INTELREAD_ARRAY   0x00FF00FF
;   41 |#define   INTELREAD_STAT    0x00700070
;   42 |#define   INTELCLR_STAT    0x00500050
;   43 |#define   INTELBLK_ERASE    0x00200020
;   44 |#define   INTELRESUME       0x00D000D0
;   45 |#define   INTELSUSPEND      0x00B000B0
;   46 |#define   INTELPROG_STD   0x00400040
;   47 |#define   INTELPROG_ALT   0x00100010
;   48 |#define   INTELSET_CFG1   0x00600060
;   49 |#define   INTELSET_CFG2   0x00030003
;   50 |
;   51 |/* bits for Polling (end of operation) */
;   52 |#define DQ7            0x00800080
;   53 |#define DQ5            0x00200020
;   54 |
;   55 |#define   STAT_WSMS       0x00800080
;   56 |#define   STAT_ESS        0x00400040
;   57 |#define   STAT_ES         0x00200020
;   58 |#define   STAT_PS         0x00100010
;   59 |#define   STAT_VPPS       0x00080008
;   60 |#define   STAT_PSS        0x00040004
;   61 |#define   STAT_DPS        0x00020002
;   62 |#define   STAT_R          0x00010001
;   63 |
;   64 |/* result of command */
;   65 |#define SUCCESS         0x0
;   66 |#define FAILURE         0x1
;   67 |#define WRITE_ERROR      0x3
;   68 |#define DATA_ERROR      0x4
;   69 |
;   70 |#define MANU_ID_AMD       0x0001
;   71 |#define MANU_ID_TOSHIBA   0x0098
;   72 |#define MANU_ID_INTEL     0x0089
;   73 |#define MANU_ID_FUJITSU   0x0004
;   74 |
;   75 |#define   AM29LV200TB_ID     0x223B
;   76 |#define   AM29LV200BB_ID     0x22BF
;   77 |#define   AM29LV400TB_ID     0x22B9
;   78 |#define   AM29LV400BB_ID     0x22BA
;   79 |#define   AM29LV800TB_ID     0x22DA
;   80 |#define   AM29LV800BB_ID     0x225B
;   81 |#define   AM29LV160TB_ID     0x22C4
;   82 |#define   AM29LV160BB_ID     0x2249
;   83 |#define   AM29BL162C_ID     0x2203
;   84 |#define   AM29BL802C_ID     0x2281
;   85 |
;   86 |#define   DT28F800F3T_ID     0x88F1
;   87 |#define   DT28F800F3B_ID     0x88F2
;   88 |#define   DT28F160F3T_ID     0x88F3
;   89 |#define   DT28F160F3B_ID     0x88F4
;   90 |
;   91 |#define   TC58FVT400FT_ID     0x00CD
;   92 |#define   TC58FVB400FT_ID     0x004C
;   93 |#define   TC58FVT800FT_ID     0x004F
;   94 |#define   TC58FVB800FT_ID     0x00CE
;   95 |#define   TC58FVT160FT_ID     0x00C2
;   96 |#define   TC58FVB160FT_ID     0x0043
;   97 |
;   98 |#define	  MBM29DL323TE_ID	  0x2250 //AMD compatible
;   99 |
;  100 |#define   KB_1_SIZE           0x00000400
;  101 |#define   KB_2_SIZE           0x00000800
;  102 |#define   KB_4_SIZE           0x00001000
;  103 |#define   KB_8_SIZE           0x00002000
;  104 |#define   KB_16_SIZE          0x00004000
;  105 |#define   KB_32_SIZE          0x00008000
;  106 |#define   KB_64_SIZE          0x00010000
;  107 |#define   KB_128_SIZE         0x00020000
;  108 |#define   KB_256_SIZE         0x00040000
;  109 |#define   KB_512_SIZE         0x00080000
;  110 |#define   MB_1_SIZE           0x00100000
;  111 |#define   MB_2_SIZE           0x00200000
;  112 |#define   MB_4_SIZE           0x00400000
;  113 |#define   MB_8_SIZE           0x00800000
;  114 |#define   MB_16_SIZE          0x01000000
;  115 |#define   MB_32_SIZE          0x02000000
;  116 |#define   MB_64_SIZE          0x04000000
;  117 |#define   MB_128_SIZE         0x08000000
;  118 |
;  119 |// Global string for containing status messages...
;  120 |char szStatusMessage[7][80];
;  121 |
;  122 |void main (void)
;  123 |{     
	.sdecl	"code.flash",CODE
	.sect	"code.flash"
	.align	4
	.symb	LINE, 123
	.symb	TYPE, 265, 'X', 8, #1, 26, 0
	.symb	GFUN, "main", main, #265, 0, 32, 0
	.symb	ALAB, main, #265
main:
	.symb	TYPE, 266, 'Z', #2, 19
	.symb	IDEN, "szFlashName", -24, #266, 129, 0x5
	.symb	IDEN, "uiBaseFlashAddr", -1, #18, 131, 0x5
	.symb	IDEN, "uiCurrentFlashAddr", -1, #18, 131, 0x5
	.symb	IDEN, "uiFlashSize", -1, #18, 131, 0x5
	.symb	IDEN, "uiBaseSramAddr", -1, #18, 131, 0x5
	.symb	IDEN, "uiCurrentSramAddr", -1, #18, 131, 0x5
	.symb	IDEN, "uiSramSize", -1, #18, 131, 0x5
	.symb	IDEN, "uiCurrentCount", -1, #18, 131, 0x5
	.symb	IDEN, "uiID", -1, #18, 131, 0x5
	.symb	IDEN, "i", -1, #18, 131, 0x5
	mov16	d15,#0				; 0
	.symb	SOFF, 32
	.symb	LTIM, "uiBaseFlashAddr", -1, 0, 0x45
	.symb	LTIM, "uiCurrentFlashAddr", -1, 0, 0x45
	.symb	LTIM, "uiFlashSize", -1, 0, 0x45
	.symb	LTIM, "uiBaseSramAddr", -1, 0, 0x45
	.symb	LTIM, "uiCurrentSramAddr", -1, 0, 0x45
	.symb	LTIM, "uiSramSize", -1, 0, 0x45
	.symb	LTIM, "uiCurrentCount", -1, 0, 0x45
	.symb	LTIM, "uiID", -1, 0, 0x45
	.symb	LTIM, "i", -1, 0, 0x45
	sub16.a	sp,#32
;  124 |   char szFlashName[20];
;  125 |
;  126 |   unsigned int uiBaseFlashAddr;
;  127 |   unsigned int uiCurrentFlashAddr;
;  128 |   unsigned int uiFlashSize;
;  129 |
;  130 |   unsigned int uiBaseSramAddr;
;  131 |   unsigned int uiCurrentSramAddr;
;  132 |   unsigned int uiSramSize;
;  133 |
;  134 |   unsigned int uiCurrentCount;
;  135 |   unsigned int uiID;
;  136 |   unsigned int i;
;  137 |
;  138 |   // Initialise the status strings...
;  139 |   for (i=0; i < 7; i++)
	.symb	LINE, 139
	movh.a	a7,#@his(szStatusMessage)
	lea	a7,[a7]@los(szStatusMessage)
	mov16.a	a15,#6				; 6
_100:
	.symb	LTIM, "uiBaseFlashAddr", 14, 0, 0xcd
	.symb	LTIM, "uiBaseFlashAddr", 14, 0, 0x4d
	.symb	LTIM, "uiBaseFlashAddr", 14, 0, 0xcd
	.symb	LTIM, "uiBaseSramAddr", 15, 0, 0xcd
	.symb	LTIM, "uiBaseSramAddr", 15, 0, 0x4d
	.symb	LTIM, "uiBaseSramAddr", 10, 0, 0xcd
	.symb	LTIM, "uiSramSize", 15, 0, 0xcd
	.symb	LTIM, "uiSramSize", 15, 0, 0x4d
	.symb	LTIM, "uiSramSize", 15, 0, 0xcd
	.symb	LTIM, "uiSramSize", 15, 0, 0x4d
	.symb	LTIM, "uiSramSize", 15, 0, 0xcd
	.symb	LTIM, "uiSramSize", 15, 0, 0x4d
	.symb	LTIM, "uiSramSize", 15, 0, 0xcd
	.symb	LTIM, "uiSramSize", 15, 0, 0x4d
	.symb	LTIM, "uiSramSize", 13, 0, 0xcd
	.symb	LTIM, "uiBaseFlashAddr", 14, 0, 0x4d
	.symb	LTIM, "uiBaseFlashAddr", 4, 0, 0xcd
	.symb	LTIM, "uiBaseFlashAddr", 4, 0, 0x4d
	.symb	LTIM, "uiBaseFlashAddr", 14, 0, 0xcd
	.symb	LTIM, "uiID", 2, 0, 0xcd
	.symb	LTIM, "uiID", 2, 0, 0x4d
	.symb	LTIM, "uiID", 8, 0, 0xcd
;  140 |      szStatusMessage[i][0] = '\0';
	.symb	LINE, 140
	nop
	st16.b	[a7],d15			; __#P1
	.symb	LINE, 139
	lea	a7,[a7]80			; __#P1
	isync
	loop	a15,_100
;  141 |
;  142 |   strcpy(szStatusMessage[0], "FLASH Programmer,  Version 1.0.2,  9-Jul-2002");
	.symb	LINE, 142
	movh.a	a4,#@his(szStatusMessage)
	lea	a4,[a4]@los(szStatusMessage)
	movh.a	a5,#@his(_3)
	lea	a5,[a5]@los(_3)
	callg	strcpy
	mov	d15,#-4096			; -4096
	mov	d10,#-4096			; -4096
;  143 |
;  144 |   // Setup base address of flash...
;  145 |   uiBaseFlashAddr = *(unsigned int *)0xF0000520;
	.symb	LINE, 145
	ld.w	d14,-268434144
;  146 |   uiBaseFlashAddr &= 0xFFFFF000;
	.symb	LINE, 146
	and16	d14,d15
;  147 |
;  148 |   // Setup base address of SRAM...
;  149 |   uiBaseSramAddr = *(unsigned int *)0xF0000524;
	.symb	LINE, 149
	ld.w	d15,-268434140
;  150 |   uiBaseSramAddr &= 0xFFFFF000;
	.symb	LINE, 150
	and16	d10,d15
;  151 |
;  152 |   // Setup size of SRAM...
;  153 |   uiSramSize = *(unsigned int *)0xF0000524;
;  154 |   uiSramSize >>= 4;
	.symb	LINE, 154
	sh16	d15,#-4
;  155 |   uiSramSize &= 0x0000000F;
	.symb	LINE, 155
	and	d15,d15,#15			; uiSramSize
;  156 |   uiSramSize = KB_4_SIZE << (15 - uiSramSize);
	.symb	LINE, 156
	rsub	d15,d15,#15
	mov	d13,#4096			; 4096
	sha	d13,d13,d15
;  157 |
;  158 |   uiID = Read_ID( uiBaseFlashAddr );
	.symb	LINE, 158
	mov16	d4,d14				; uiBaseFlashAddr
	callg	Read_ID
;  159 |
;  160 |if (((uiID>>16) != MANU_ID_AMD) &&
;  161 |    ((uiID>>16) != MANU_ID_TOSHIBA) &&
;  162 |	((uiID>>16) != MANU_ID_FUJITSU) &&
;  163 |    ((uiID>>16) != MANU_ID_INTEL))
	.symb	LINE, 163
	mov16	d8,d2
	sh	d15,d8,#-16
	jeq	d15,#1,_104
	ne	d7,d15,#152
	jeq	d7,#0,_104
	jeq	d15,#4,_104
	ne	d7,d15,#137
	jeq	d7,#0,_104
;  164 |    {
;  165 |      sprintf(szStatusMessage[1], "Unknown flash manufacturer ID [%X]", uiID>>16);
	.symb	LINE, 165
	movh.a	a4,#@his(szStatusMessage+80)
	lea	a4,[a4]@los(szStatusMessage+80)
	movh.a	a5,#@his(_4)
	lea	a5,[a5]@los(_4)
	st16.w	[sp],d15
	callg	sprintf
;  166 |      goto FlashErrorHandler;
	.symb	LINE, 166
	j	_161
;  167 |      }
	.symb	LINE, 167
_104:
	.symb	LTIM, "uiBaseFlashAddr", 14, 0, 0x4d
	.symb	LTIM, "uiBaseFlashAddr", 14, 0, 0xcd
	.symb	LTIM, "uiBaseSramAddr", 10, 0, 0x4d
	.symb	LTIM, "uiBaseSramAddr", 10, 0, 0xcd
	.symb	LTIM, "uiSramSize", 13, 0, 0x4d
	.symb	LTIM, "uiSramSize", 13, 0, 0xcd
	.symb	LTIM, "uiID", 8, 0, 0x4d
;  168 |
;  169 |   switch (uiID & 0xFFFF)
	.symb	LINE, 169
	mov.u	d15,#65535			; 65535
	and16	d15,d8
	addi	d15,d15,#-72
	jeq	d15,#-5,_123			; case 67
	jeq	d15,#4,_107			; case 76
	jeq	d15,#7,_110			; case 79
	addi	d15,d15,#-127
	jeq	d15,#-5,_122			; case 194
	jeq	d15,#6,_106			; case 205
	jeq	d15,#7,_111			; case 206
	addi	d15,d15,#-8508
	jeq	d15,#0,_130			; case 8707
	addi	d15,d15,#-63
	jeq	d15,#-7,_140			; case 8763
	jeq	d15,#7,_129			; case 8777
	addi	d15,d15,#-18
	jeq	d15,#-4,_138			; case 8784
	jeq	d15,#7,_113			; case 8795
	addi	d15,d15,#-45
	jeq	d15,#0,_114			; case 8833
	addi	d15,d15,#-62
	jeq	d15,#-6,_108			; case 8889
	jeq	d15,#-5,_109			; case 8890
	jeq	d15,#0,_105			; case 8895
	jeq	d15,#5,_124			; case 8900
	addi	d15,d15,#-27
	jeq	d15,#0,_112			; case 8922
	addi	d15,d15,#-26138
	jeq	d15,#-3,_115			; case 35057
	jeq	d15,#-2,_116			; case 35058
	jeq	d15,#-1,_132			; case 35059
	jeq	d15,#0,_131			; case 35060
	j	_139				; default
;  170 |      {
;  171 |      case AM29LV200TB_ID:
;  172 |         strcpy(szFlashName, "AM29LV200TB");
;  173 |         uiFlashSize = KB_512_SIZE;
;  174 |         break;
;  175 |      case AM29LV200BB_ID:
	.symb	LINE, 175
_105:
;  176 |         strcpy(szFlashName, "AM29LV200BB");
	.symb	LINE, 176
	nop
	lea	a4,[sp]8
	movh.a	a5,#@his(_6)
	lea	a5,[a5]@los(_6)
	callg	strcpy
;  177 |         uiFlashSize = KB_512_SIZE;
	.symb	LINE, 177
	j	_142
;  178 |         break;
;  179 |      case TC58FVT400FT_ID:
	.symb	LINE, 179
_106:
;  180 |         strcpy(szFlashName, "TC58FVT400FT");
	.symb	LINE, 180
	nop
	lea	a4,[sp]8
	movh.a	a5,#@his(_7)
	lea	a5,[a5]@los(_7)
	callg	strcpy
;  181 |         uiFlashSize = MB_1_SIZE;
	.symb	LINE, 181
	j	_128
;  182 |         break;
;  183 |      case TC58FVB400FT_ID:
	.symb	LINE, 183
_107:
;  184 |         strcpy(szFlashName, "TC58FVB400FT");
	.symb	LINE, 184
	nop
	lea	a4,[sp]8
	movh.a	a5,#@his(_8)
	lea	a5,[a5]@los(_8)
	callg	strcpy
;  185 |         uiFlashSize = MB_1_SIZE;
	.symb	LINE, 185
	j	_128
;  186 |         break;
;  187 |      case AM29LV400TB_ID:
	.symb	LINE, 187
_108:
;  188 |         strcpy(szFlashName, "AM29LV400TB");
	.symb	LINE, 188
	nop
	lea	a4,[sp]8
	movh.a	a5,#@his(_9)
	lea	a5,[a5]@los(_9)
	callg	strcpy
;  189 |         uiFlashSize = MB_1_SIZE;
	.symb	LINE, 189
	j	_128
;  190 |         break;
;  191 |      case AM29LV400BB_ID:
	.symb	LINE, 191
_109:
;  192 |         strcpy(szFlashName, "AM29LV400BB");
	.symb	LINE, 192
	nop
	lea	a4,[sp]8
	movh.a	a5,#@his(_10)
	lea	a5,[a5]@los(_10)
	callg	strcpy
;  193 |         uiFlashSize = MB_1_SIZE;
	.symb	LINE, 193
	j	_128
;  194 |         break;
;  195 |      case TC58FVT800FT_ID:
	.symb	LINE, 195
_110:
;  196 |         strcpy(szFlashName, "TC58FVT800FT");
	.symb	LINE, 196
	nop
	lea	a4,[sp]8
	movh.a	a5,#@his(_11)
	lea	a5,[a5]@los(_11)
	callg	strcpy
;  197 |         uiFlashSize = MB_2_SIZE;
	.symb	LINE, 197
	j	_121
;  198 |         break;
;  199 |      case TC58FVB800FT_ID:
	.symb	LINE, 199
_111:
;  200 |         strcpy(szFlashName, "TC58FVB800FT");
	.symb	LINE, 200
	nop
	lea	a4,[sp]8
	movh.a	a5,#@his(_12)
	lea	a5,[a5]@los(_12)
	callg	strcpy
;  201 |         uiFlashSize = MB_2_SIZE;
	.symb	LINE, 201
	j	_121
;  202 |         break;
;  203 |      case AM29LV800TB_ID:
	.symb	LINE, 203
_112:
;  204 |         strcpy(szFlashName, "AM29LV800TB");
	.symb	LINE, 204
	nop
	lea	a4,[sp]8
	movh.a	a5,#@his(_13)
	lea	a5,[a5]@los(_13)
	callg	strcpy
;  205 |         uiFlashSize = MB_2_SIZE;
	.symb	LINE, 205
	j	_121
;  206 |         break;
;  207 |      case AM29LV800BB_ID: 
	.symb	LINE, 207
_113:
;  208 |         strcpy(szFlashName, "AM29LV800BB");
	.symb	LINE, 208
	nop
	lea	a4,[sp]8
	movh.a	a5,#@his(_14)
	lea	a5,[a5]@los(_14)
	callg	strcpy
;  209 |         uiFlashSize = MB_2_SIZE;
	.symb	LINE, 209
	j	_121
;  210 |         break;
;  211 |      case AM29BL802C_ID:
	.symb	LINE, 211
_114:
;  212 |         strcpy(szFlashName, "AM29BL802C");
	.symb	LINE, 212
	nop
	lea	a4,[sp]8
	movh.a	a5,#@his(_15)
	lea	a5,[a5]@los(_15)
	callg	strcpy
;  213 |         uiFlashSize = MB_2_SIZE/4;
	.symb	LINE, 213
	j	_142
;  214 |         break;
;  215 |      case DT28F800F3T_ID:
	.symb	LINE, 215
_115:
;  216 |         strcpy(szFlashName, "DT28F800F3T");
	.symb	LINE, 216
	nop
	lea	a4,[sp]8
	movh.a	a5,#@his(_16)
	lea	a5,[a5]@los(_16)
	callg	strcpy
;  217 |         uiFlashSize = MB_2_SIZE;
	.symb	LINE, 217
	j	_121
;  218 |         break;
;  219 |      case DT28F800F3B_ID:
	.symb	LINE, 219
_116:
;  220 |         strcpy(szFlashName, "DT28F800F3B");
	.symb	LINE, 220
	nop
	lea	a4,[sp]8
	movh.a	a5,#@his(_17)
	lea	a5,[a5]@los(_17)
	callg	strcpy
;  221 |         uiFlashSize = MB_2_SIZE;
	.symb	LINE, 221
_121:
	.symb	LTIM, "uiFlashSize", 12, 0, 0xcd
	movh	d12,#0x20			; 2097152
;  222 |         break;
	.symb	LINE, 222
	j	_146
;  223 |      case TC58FVT160FT_ID:
	.symb	LINE, 223
_122:
;  224 |         strcpy(szFlashName, "TC58FVT160FT");
	.symb	LINE, 224
	nop
	lea	a4,[sp]8
	movh.a	a5,#@his(_18)
	lea	a5,[a5]@los(_18)
	callg	strcpy
;  225 |         uiFlashSize = MB_4_SIZE;
	.symb	LINE, 225
	j	_137
;  226 |         break;
;  227 |      case TC58FVB160FT_ID:
	.symb	LINE, 227
_123:
;  228 |         strcpy(szFlashName, "TC58FVB160FT");
	.symb	LINE, 228
	nop
	lea	a4,[sp]8
	movh.a	a5,#@his(_19)
	lea	a5,[a5]@los(_19)
	callg	strcpy
;  229 |         uiFlashSize = MB_4_SIZE;
	.symb	LINE, 229
	j	_137
;  230 |         break;
;  231 |      case AM29LV160TB_ID:
	.symb	LINE, 231
_124:
;  232 |         strcpy(szFlashName, "AM29LV160TB");
	.symb	LINE, 232
	nop
	lea	a4,[sp]8
	movh.a	a5,#@his(_20)
	lea	a5,[a5]@los(_20)
	callg	strcpy
;  233 |         uiFlashSize = MB_4_SIZE/4;
	.symb	LINE, 233
_128:
	.symb	LTIM, "uiFlashSize", 12, 0, 0x4d
	.symb	LTIM, "uiFlashSize", 12, 0, 0xcd
	movh	d12,#0x10			; 1048576
;  234 |         break;
	.symb	LINE, 234
	j	_146
;  235 |      case AM29LV160BB_ID: 
	.symb	LINE, 235
_129:
;  236 |         strcpy(szFlashName, "AM29LV160BB");
	.symb	LINE, 236
	nop
	lea	a4,[sp]8
	movh.a	a5,#@his(_21)
	lea	a5,[a5]@los(_21)
	callg	strcpy
;  237 |         uiFlashSize = MB_4_SIZE;
	.symb	LINE, 237
	j	_137
;  238 |         break;
;  239 |      case AM29BL162C_ID:
	.symb	LINE, 239
_130:
;  240 |         strcpy(szFlashName, "AM29BL162C");
	.symb	LINE, 240
	nop
	lea	a4,[sp]8
	movh.a	a5,#@his(_22)
	lea	a5,[a5]@los(_22)
	callg	strcpy
;  241 |         uiFlashSize = MB_4_SIZE;
	.symb	LINE, 241
	j	_137
;  242 |         break;
;  243 |      case DT28F160F3B_ID:
	.symb	LINE, 243
_131:
;  244 |         strcpy(szFlashName, "DT28F160F3B");
	.symb	LINE, 244
	nop
	lea	a4,[sp]8
	movh.a	a5,#@his(_23)
	lea	a5,[a5]@los(_23)
	callg	strcpy
;  245 |         uiFlashSize = MB_4_SIZE;
	.symb	LINE, 245
	j	_137
;  246 |         break;
;  247 |      case DT28F160F3T_ID:
	.symb	LINE, 247
_132:
;  248 |         strcpy(szFlashName, "DT28F160F3T");
	.symb	LINE, 248
	nop
	lea	a4,[sp]8
	movh.a	a5,#@his(_24)
	lea	a5,[a5]@los(_24)
	callg	strcpy
;  249 |         uiFlashSize = MB_4_SIZE;
	.symb	LINE, 249
_137:
	.symb	LTIM, "uiFlashSize", 12, 0, 0x4d
	.symb	LTIM, "uiFlashSize", 12, 0, 0xcd
	movh	d12,#0x40			; 4194304
;  250 |         break;
	.symb	LINE, 250
	j	_146
;  251 |      case MBM29DL323TE_ID:
	.symb	LINE, 251
_138:
	.symb	LTIM, "uiFlashSize", 12, 0, 0x4d
	.symb	LTIM, "uiFlashSize", 12, 0, 0xcd
;  252 |         strcpy(szFlashName, "MBM29DL323TE");
	.symb	LINE, 252
	nop
	lea	a4,[sp]8
	movh.a	a5,#@his(_25)
	lea	a5,[a5]@los(_25)
	callg	strcpy
;  253 |         uiFlashSize = MB_8_SIZE;
	.symb	LINE, 253
	movh	d12,#0x80			; 8388608
;  254 |         break;
	.symb	LINE, 254
	j	_146
;  255 |      default:
	.symb	LINE, 255
_139:
;  256 |         strcpy(szStatusMessage[1], "Unknown / Unsupported flash size");
	.symb	LINE, 256
	movh.a	a4,#@his(szStatusMessage+80)
	lea	a4,[a4]@los(szStatusMessage+80)
	movh.a	a5,#@his(_26)
	lea	a5,[a5]@los(_26)
	callg	strcpy
;  257 |         goto FlashErrorHandler;
	.symb	LINE, 257
	j	_161
	.symb	LINE, 171
_140:
	.symb	LTIM, "uiBaseFlashAddr", 14, 0, 0x4d
	.symb	LTIM, "uiBaseFlashAddr", 14, 0, 0xcd
	.symb	LTIM, "uiBaseSramAddr", 10, 0, 0x4d
	.symb	LTIM, "uiBaseSramAddr", 10, 0, 0xcd
	.symb	LTIM, "uiSramSize", 13, 0, 0x4d
	.symb	LTIM, "uiSramSize", 13, 0, 0xcd
	.symb	LINE, 172
	nop
	lea	a4,[sp]8
	movh.a	a5,#@his(_5)
	lea	a5,[a5]@los(_5)
	callg	strcpy
	.symb	LINE, 173
_142:
	.symb	LTIM, "uiFlashSize", 12, 0, 0x4d
	.symb	LTIM, "uiFlashSize", 12, 0, 0xcd
	movh	d12,#0x8			; 524288
;  258 |      }
	.symb	LINE, 258
_146:
;  259 |
;  260 |   if (uiSramSize >= MB_1_SIZE)
	.symb	LINE, 260
	movh	d11,#0x10			; 1048576
	jlt.u	d13,d11,_147
	sh	d15,d13,#-20
;  261 |      sprintf(szStatusMessage[1], "Determined SRAM is of %dMB size", uiSramSize/MB_1_SIZE);
	.symb	LINE, 261
	movh.a	a4,#@his(szStatusMessage+80)
	lea	a4,[a4]@los(szStatusMessage+80)
	movh.a	a5,#@his(_27)
	lea	a5,[a5]@los(_27)
	st16.w	[sp],d15
	callg	sprintf
	j	_148
_147:
	sh	d15,d13,#-10
;  262 |   else 
;  263 |      sprintf(szStatusMessage[1], "Determined SRAM is of %dKB size",  uiSramSize/KB_1_SIZE);
	.symb	LINE, 263
	movh.a	a4,#@his(szStatusMessage+80)
	lea	a4,[a4]@los(szStatusMessage+80)
	movh.a	a5,#@his(_28)
	lea	a5,[a5]@los(_28)
	st16.w	[sp],d15
	callg	sprintf
_148:
;  264 |
;  265 |   if (uiFlashSize >= MB_1_SIZE)
	.symb	LINE, 265
	jlt.u	d12,d11,_149
	sh	d15,d12,#-20
;  266 |      sprintf(szStatusMessage[2], "Determined flash is of %dMB size, type is %s", uiFlashSize/MB_1_SIZE, szFlashName);
	.symb	LINE, 266
	movh.a	a4,#@his(szStatusMessage+160)
	lea	a4,[a4]@los(szStatusMessage+160)
	movh.a	a5,#@his(_29)
	lea	a5,[a5]@los(_29)
	lea	a15,[sp]8
	st16.a	[sp]4,a15
	st16.w	[sp],d15
	callg	sprintf
	j	_150
_149:
	sh	d15,d12,#-10
;  267 |   else 
;  268 |      sprintf(szStatusMessage[2], "Determined flash is of %dKB size, type is %s", uiFlashSize/KB_1_SIZE, szFlashName);
	.symb	LINE, 268
	movh.a	a4,#@his(szStatusMessage+160)
	lea	a4,[a4]@los(szStatusMessage+160)
	movh.a	a5,#@his(_30)
	lea	a5,[a5]@los(_30)
	lea	a15,[sp]8
	st16.a	[sp]4,a15
	st16.w	[sp],d15
	callg	sprintf
_150:
	.symb	LTIM, "uiFlashSize", 12, 0, 0x4d
	.symb	LTIM, "uiFlashSize", 12, 0, 0xcd
;  269 |
;  270 |   /*
;  271 |      We can only program up to the size of the external SRAM
;  272 |   */
;  273 |   if (uiFlashSize > uiSramSize)
	.symb	LINE, 273
	jge.u	d13,d12,_151
;  274 |      uiFlashSize = uiSramSize;
	.symb	LINE, 274
	mov16	d12,d13				; uiFlashSize
_151:
	.symb	LTIM, "uiBaseFlashAddr", 14, 0, 0x4d
	.symb	LTIM, "uiBaseFlashAddr", 5, 0, 0xcd
	.symb	LTIM, "uiBaseFlashAddr", 5, 0, 0x4d
	.symb	LTIM, "uiBaseFlashAddr", 14, 0, 0xcd
	.symb	LTIM, "uiSramSize", 13, 0, 0x4d
	.symb	LTIM, "uiCurrentCount", 13, 0, 0xcd
	.symb	LTIM, "uiCurrentSramAddr", 11, 0, 0xcd
	.symb	LTIM, "uiFlashSize", 12, 0, 0x4d
	.symb	LTIM, "uiCurrentFlashAddr", 12, 0, 0xcd
;  275 |
;  276 |   strcpy(szStatusMessage[3], "Erasing flash device...");
	.symb	LINE, 276
	movh.a	a13,#@his(szStatusMessage+240)
	lea	a13,[a13]@los(szStatusMessage+240)
	movh.a	a5,#@his(_31)
	lea	a5,[a5]@los(_31)
	mov16.aa a4,a13
	callg	strcpy
	mov16	d5,d14				; uiBaseFlashAddr
	mov16	d4,d8
;  277 |   Chip_Erase( uiID, uiBaseFlashAddr );
	.symb	LINE, 277
	callg	Chip_Erase
;  278 |   strcat(szStatusMessage[3], "completed");
	.symb	LINE, 278
	movh.a	a14,#@his(_32)
	lea	a14,[a14]@los(_32)
	mov16.aa a5,a14
	mov16.aa a4,a13
	callg	strcat
;  279 |   
;  280 |   strcpy(szStatusMessage[4], "Programming flash device...");
	.symb	LINE, 280
	movh.a	a13,#@his(szStatusMessage+320)
	lea	a13,[a13]@los(szStatusMessage+320)
	movh.a	a5,#@his(_33)
	lea	a5,[a5]@los(_33)
	mov16.aa a4,a13
	callg	strcpy
;  281 |
;  282 |   uiCurrentCount       = uiFlashSize / 4;
	.symb	LINE, 282
	sh	d9,d12,#-2
	mov16	d13,d9				; uiCurrentCount
;  283 |   uiCurrentSramAddr    = uiBaseSramAddr;
	.symb	LINE, 283
	mov16	d11,d10				; uiCurrentSramAddr
;  284 |   uiCurrentFlashAddr   = uiBaseFlashAddr;
	.symb	LINE, 284
	mov16	d12,d14				; uiCurrentFlashAddr
;  285 |
;  286 |   while (uiCurrentCount--)
	.symb	LINE, 286
	j	_155
_152:
	.symb	LTIM, "uiBaseFlashAddr", 14, 0, 0x4d
	.symb	LTIM, "uiBaseFlashAddr", 7, 0, 0xcd
	.symb	LTIM, "uiCurrentFlashAddr", 12, 0, 0x4d
	.symb	LTIM, "uiCurrentFlashAddr", 5, 0, 0xcd
	.symb	LTIM, "uiCurrentFlashAddr", 5, 0, 0x4d
	.symb	LTIM, "uiCurrentFlashAddr", 12, 0, 0xcd
	.symb	LTIM, "uiBaseFlashAddr", 7, 0, 0x4d
	.symb	LTIM, "uiBaseFlashAddr", 14, 0, 0xcd
	.symb	LTIM, "uiCurrentCount", 13, 0, 0x4d
	.symb	LTIM, "uiCurrentCount", 13, 0, 0xcd
	.symb	LTIM, "uiCurrentCount", 13, 0, 0x4d
	.symb	LTIM, "uiCurrentCount", 13, 0, 0xcd
;  287 |      {   
;  288 |      if (Program_Word(uiID,
;  289 |                       uiCurrentFlashAddr,
;  290 |                       *(unsigned int *)uiCurrentSramAddr,
;  291 |                       uiBaseFlashAddr) != SUCCESS)
	.symb	LINE, 291
	mov16.a	a15,d11				; uiCurrentSramAddr
	mov16	d7,d14				; uiBaseFlashAddr
	ld16.w	d6,[a15]
	mov16	d5,d12				; uiCurrentFlashAddr
	mov16	d4,d8
	callg	Program_Word
	jeq	d2,#0,_153
;  292 |         {
;  293 |         // Failed to program.....try again...
;  294 |         uiCurrentCount++;
	.symb	LINE, 294
	add16	d13,#1				; uiCurrentCount
;  295 |         continue;
	.symb	LINE, 295
	j	_155
;  296 |         }
	.symb	LINE, 296
_153:
	.symb	LTIM, "uiCurrentFlashAddr", 12, 0, 0x4d
	.symb	LTIM, "uiCurrentFlashAddr", 12, 0, 0xcd
	.symb	LTIM, "uiCurrentFlashAddr", 12, 0, 0x4d
	.symb	LTIM, "uiCurrentFlashAddr", 12, 0, 0xcd
	.symb	LTIM, "uiCurrentSramAddr", 11, 0, 0x4d
	.symb	LTIM, "uiCurrentSramAddr", 11, 0, 0xcd
	.symb	LTIM, "uiCurrentSramAddr", 11, 0, 0x4d
	.symb	LTIM, "uiCurrentSramAddr", 11, 0, 0xcd
;  297 |
;  298 |      uiCurrentFlashAddr += 4;
	.symb	LINE, 298
	add16	d12,#4				; uiCurrentFlashAddr
;  299 |      uiCurrentSramAddr  += 4;
	.symb	LINE, 299
	add16	d11,#4				; uiCurrentSramAddr
	.symb	LINE, 286
_155:
	.symb	LTIM, "uiCurrentCount", 13, 0, 0x4d
	.symb	LTIM, "uiCurrentCount", 15, 0, 0xcd
	.symb	LTIM, "uiCurrentCount", 15, 0, 0x4d
	.symb	LTIM, "uiCurrentCount", 13, 0, 0xcd
	.symb	LTIM, "uiCurrentCount", 13, 0, 0x4d
	.symb	LTIM, "uiCurrentCount", 13, 0, 0xcd
	.symb	LTIM, "uiCurrentCount", 13, 0, 0x4d
	.symb	LTIM, "uiCurrentCount", 7, 0, 0xcd
	.symb	LTIM, "uiCurrentSramAddr", 11, 0, 0x4d
	.symb	LTIM, "uiCurrentSramAddr", 15, 0, 0xcd
	.symb	LTIM, "uiCurrentFlashAddr", 12, 0, 0x4d
	.symb	LTIM, "uiCurrentFlashAddr", 6, 0, 0xcd
	mov16	d15,d13				; uiCurrentCount
	add16	d13,#-1				; uiCurrentCount
	jne	d15,#0,_152			; uiCurrentCount
	mov16.aa a5,a14
;  300 |      }
;  301 |
;  302 |   strcat(szStatusMessage[4], "completed");
	.symb	LINE, 302
	mov16.aa a4,a13
	callg	strcat
;  303 |
;  304 |   strcpy(szStatusMessage[5], "Verifying flash device...");
	.symb	LINE, 304
	movh.a	a13,#@his(szStatusMessage+400)
	lea	a13,[a13]@los(szStatusMessage+400)
	movh.a	a5,#@his(_34)
	lea	a5,[a5]@los(_34)
	mov16.aa a4,a13
	callg	strcpy
;  305 |
;  306 |   uiCurrentCount       = uiFlashSize / 4;
	.symb	LINE, 306
	mov16	d7,d9				; uiCurrentCount
;  307 |   uiCurrentSramAddr    = uiBaseSramAddr;
	.symb	LINE, 307
	mov16	d15,d10				; uiCurrentSramAddr
;  308 |   uiCurrentFlashAddr   = uiBaseFlashAddr;
	.symb	LINE, 308
	mov16	d6,d14				; uiCurrentFlashAddr
;  309 |
;  310 |   while (uiCurrentCount--)
	.symb	LINE, 310
	j	_158
_156:
	.symb	LTIM, "uiCurrentSramAddr", 15, 0, 0x4d
	.symb	LTIM, "uiCurrentSramAddr", 15, 0, 0xcd
	.symb	LTIM, "uiCurrentSramAddr", 15, 0, 0x4d
	.symb	LTIM, "uiCurrentFlashAddr", 6, 0, 0x4d
	.symb	LTIM, "uiCurrentCount", 7, 0, 0x4d
;  311 |      {   
;  312 |      if (*(unsigned int *)uiCurrentSramAddr != *(unsigned int *)uiCurrentFlashAddr)
	.symb	LINE, 312
	mov16.a	a15,d15				; uiCurrentSramAddr
	ld16.w	d5,[a15]
	mov16.a	a15,d6				; uiCurrentFlashAddr
	ld16.w	d4,[a15]
	jeq	d5,d4,_157
;  313 |         {
;  314 |         sprintf(szStatusMessage[6], "Failed to verify at address %8.8X", uiCurrentSramAddr);
	.symb	LINE, 314
	movh.a	a4,#@his(szStatusMessage+480)
	lea	a4,[a4]@los(szStatusMessage+480)
	movh.a	a5,#@his(_35)
	lea	a5,[a5]@los(_35)
	st16.w	[sp],d15			; uiCurrentSramAddr
	callg	sprintf
;  315 |         goto FlashErrorHandler;
	.symb	LINE, 315
	j	_161
;  316 |         }
	.symb	LINE, 316
_157:
	.symb	LTIM, "uiCurrentCount", 7, 0, 0xcd
	.symb	LTIM, "uiCurrentSramAddr", 15, 0, 0xcd
	.symb	LTIM, "uiCurrentFlashAddr", 6, 0, 0xcd
	.symb	LTIM, "uiCurrentFlashAddr", 6, 0, 0x4d
	.symb	LTIM, "uiCurrentFlashAddr", 6, 0, 0xcd
	.symb	LTIM, "uiCurrentFlashAddr", 6, 0, 0x4d
	.symb	LTIM, "uiCurrentFlashAddr", 6, 0, 0xcd
	.symb	LTIM, "uiCurrentSramAddr", 15, 0, 0x4d
	.symb	LTIM, "uiCurrentSramAddr", 15, 0, 0xcd
	.symb	LTIM, "uiCurrentSramAddr", 15, 0, 0x4d
	.symb	LTIM, "uiCurrentSramAddr", 15, 0, 0xcd
;  317 |      
;  318 |      uiCurrentFlashAddr += 4;
	.symb	LINE, 318
	add16	d6,#4				; uiCurrentFlashAddr
;  319 |      uiCurrentSramAddr  += 4;
	.symb	LINE, 319
	add16	d15,#4				; uiCurrentSramAddr
	.symb	LINE, 310
_158:
	.symb	LTIM, "uiCurrentCount", 7, 0, 0x4d
	.symb	LTIM, "uiCurrentCount", 5, 0, 0xcd
	.symb	LTIM, "uiCurrentCount", 5, 0, 0x4d
	.symb	LTIM, "uiCurrentCount", 7, 0, 0xcd
	.symb	LTIM, "uiCurrentCount", 7, 0, 0x4d
	.symb	LTIM, "uiCurrentCount", 7, 0, 0xcd
	.symb	LTIM, "uiCurrentFlashAddr", 6, 0, 0x4d
	.symb	LTIM, "uiCurrentSramAddr", 15, 0, 0x4d
	.symb	LTIM, "uiCurrentCount", 7, 0, 0x4d
	mov16	d5,d7				; uiCurrentCount
	add16	d7,#-1				; uiCurrentCount
	jne	d5,#0,_156			; uiCurrentCount
;  320 |      }
;  321 |   strcat(szStatusMessage[5], "completed");
	.symb	LINE, 321
	mov16.aa a5,a14
	mov16.aa a4,a13
	callg	strcat
;  322 |
;  323 |   strcpy(szStatusMessage[6], "Flash programming completed successfully.");
	.symb	LINE, 323
	movh.a	a4,#@his(szStatusMessage+480)
	lea	a4,[a4]@los(szStatusMessage+480)
	movh.a	a5,#@his(_36)
	lea	a5,[a5]@los(_36)
	callg	strcpy
;  324 |
;  325 |
;  326 |   // Flow through and loop for ever.
;  327 |
;  328 |FlashErrorHandler:
	.symb	LINE, 328
_161:
	.symb	IDEN, "FlashErrorHandler", _161, #15, 130, 0x4
;  329 |   _debug();
	.symb	LINE, 329
	debug
;  330 |   while (1);
	.symb	LINE, 330
_162:
	j	_162
;  331 |}
	.symb	LINE, 331
	ret16
	.symb	LTIM, "uiBaseFlashAddr", 14, 0, 0x4d
	.symb	LTIM, "uiBaseSramAddr", 10, 0, 0x4d
	.symb	EFUN
;  332 |
;  333 |/* read id */
;  334 |unsigned int Read_ID( unsigned int uiFlashBase )
;  335 |{
	.symb	LINE, 335
	.symb	TYPE, 268, 'X', 8, #18, 26, 1, #18
	.symb	GFUN, "Read_ID", Read_ID, #268, 0, 0, 0
	.symb	ALAB, Read_ID, #268
Read_ID:
	.symb	IDEN, "uiFlashBase", 4, #18, 0, 0x80d
	.symb	IDEN, "uiID", -1, #18, 131, 0x5
	.symb	SOFF, 0
	.symb	LTIM, "uiFlashBase", 4, 0, 0x8cd
	.symb	LTIM, "uiID", -1, 0, 0x45
	.symb	LTIM, "uiFlashBase", 4, 0, 0x84d
	.symb	LTIM, "uiFlashBase", 14, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 14, 0, 0x84d
	.symb	LTIM, "uiFlashBase", 4, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 4, 0, 0x84d
	.symb	LTIM, "uiFlashBase", 14, 0, 0x8cd
	.symb	LTIM, "uiID", 15, 0, 0xcd
	.symb	LTIM, "uiFlashBase", 14, 0, 0x84d
	.symb	LTIM, "uiFlashBase", 4, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 4, 0, 0x84d
	.symb	LTIM, "uiID", 15, 0, 0x4d
	.symb	LTIM, "uiID", 15, 0, 0xcd
;  336 |	unsigned int uiID = 0;;
	.symb	LINE, 336
	mov16	d14,d4				; uiFlashBase
;  337 |
;  338 |	uiID = AMD_Flash_ID( uiFlashBase );
	.symb	LINE, 338
	callg	AMD_Flash_ID
	mov16	d15,d2				; uiID
;  339 |
;  340 |	if (((uiID>>16) != MANU_ID_AMD) && ((uiID>>16) != MANU_ID_TOSHIBA) 
;  341 |			&& ((uiID>>16) != MANU_ID_FUJITSU)) uiID = Intel_Flash_ID(uiFlashBase);
	.symb	LINE, 341
	sh	d2,d2,#-16
	jeq	d2,#1,_169
	ne	d7,d2,#152
	jeq	d7,#0,_169
	jeq	d2,#4,_169
	mov16	d4,d14				; uiFlashBase
	callg	Intel_Flash_ID
	mov16	d15,d2				; uiID
_169:
	.symb	LTIM, "uiID", 15, 0, 0x4d
	.symb	LTIM, "uiID", 2, 0, 0xcd
;  342 |
;  343 |	return uiID;
	.symb	LINE, 343
	mov16	d2,d15				; uiID
;  344 |}
	.symb	LINE, 344
	ret16
	.symb	LTIM, "uiID", 2, 0, 0x4d
	.symb	EFUN
;  345 |
;  346 |
;  347 |unsigned int Chip_Erase(unsigned int uiID, unsigned int uiFlashBase)
;  348 |{
	.symb	LINE, 348
	.symb	TYPE, 269, 'X', 8, #18, 26, 2, #18, #18
	.symb	GFUN, "Chip_Erase", Chip_Erase, #269, 0, 0, 0
	.symb	ALAB, Chip_Erase, #269
Chip_Erase:
	.symb	IDEN, "uiID", 4, #18, 0, 0x80d
	.symb	IDEN, "uiFlashBase", 5, #18, 0, 0x80d
	.symb	IDEN, "uiRetVal", -1, #18, 131, 0x5
;  349 |   unsigned int uiRetVal;
;  350 |
;  351 |   if ((uiID>>16) == MANU_ID_INTEL)
	.symb	LINE, 351
	sh	d15,d4,#-16
	.symb	SOFF, 0
	.symb	LTIM, "uiID", 4, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 5, 0, 0x8cd
	.symb	LTIM, "uiRetVal", -1, 0, 0x45
	.symb	LTIM, "uiID", 4, 0, 0x84d
	.symb	LTIM, "uiFlashBase", 5, 0, 0x84d
	.symb	LTIM, "uiRetVal", 2, 0, 0xcd
	eq	d15,d15,#137
	jeq	d15,#0,_170
;  352 |      uiRetVal = Intel_Chip_Erase(uiID, uiFlashBase);
	.symb	LINE, 352
	callg	Intel_Chip_Erase
	j	_171
_170:
	.symb	LTIM, "uiFlashBase", 5, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 5, 0, 0x84d
	.symb	LTIM, "uiFlashBase", 4, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 4, 0, 0x84d
	.symb	LTIM, "uiRetVal", 2, 0, 0x4d
	.symb	LTIM, "uiRetVal", 2, 0, 0xcd
;  353 |   else
;  354 |      uiRetVal = AMD_Chip_Erase(uiFlashBase);
	.symb	LINE, 354
	mov16	d4,d5				; uiFlashBase
	callg	AMD_Chip_Erase
_171:
;  355 |
;  356 |   return uiRetVal;
;  357 |}
	.symb	LINE, 357
	ret16
	.symb	LTIM, "uiRetVal", 2, 0, 0x4d
	.symb	EFUN
;  358 |
;  359 |unsigned int Program_Word(unsigned int uiID, unsigned int uiAddress, unsigned int uiValue, unsigned int uiFlashBase )
;  360 |{
	.symb	LINE, 360
	.symb	TYPE, 270, 'X', 8, #18, 26, 4, #18, #18, #18, #18
	.symb	GFUN, "Program_Word", Program_Word, #270, 0, 0, 0
	.symb	ALAB, Program_Word, #270
Program_Word:
	.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", -1, #18, 131, 0x5
	.symb	SOFF, 0
	.symb	LTIM, "uiID", 4, 0, 0x8cd
	.symb	LTIM, "uiAddress", 5, 0, 0x8cd
	.symb	LTIM, "uiValue", 6, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 7, 0, 0x8cd
	.symb	LTIM, "uiRetVal", -1, 0, 0x45
	.symb	LTIM, "uiID", 4, 0, 0x84d
	.symb	LTIM, "uiAddress", 5, 0, 0x84d
	.symb	LTIM, "uiAddress", 4, 0, 0x8cd
	.symb	LTIM, "uiAddress", 4, 0, 0x84d
	.symb	LTIM, "uiValue", 6, 0, 0x84d
	.symb	LTIM, "uiValue", 5, 0, 0x8cd
	.symb	LTIM, "uiValue", 5, 0, 0x84d
	.symb	LTIM, "uiFlashBase", 7, 0, 0x84d
	.symb	LTIM, "uiRetVal", 2, 0, 0xcd
;  361 |   unsigned int uiRetVal;
;  362 |
;  363 |   if ((uiID>>16) == MANU_ID_INTEL)
	.symb	LINE, 363
	sh	d4,d4,#-16
	eq	d4,d4,#137
	jeq	d4,#0,_172
;  364 |      uiRetVal = Intel_Program_Word(uiAddress, uiValue);
	.symb	LINE, 364
	mov16	d4,d5				; uiAddress
	mov16	d5,d6				; uiValue
	callg	Intel_Program_Word
	j	_173
_172:
	.symb	LTIM, "uiAddress", 5, 0, 0x8cd
	.symb	LTIM, "uiValue", 6, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 7, 0, 0x8cd
	.symb	LTIM, "uiRetVal", 2, 0, 0x4d
	.symb	LTIM, "uiAddress", 5, 0, 0x84d
	.symb	LTIM, "uiAddress", 4, 0, 0x8cd
	.symb	LTIM, "uiAddress", 4, 0, 0x84d
	.symb	LTIM, "uiValue", 6, 0, 0x84d
	.symb	LTIM, "uiValue", 5, 0, 0x8cd
	.symb	LTIM, "uiValue", 5, 0, 0x84d
	.symb	LTIM, "uiFlashBase", 7, 0, 0x84d
	.symb	LTIM, "uiFlashBase", 6, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 6, 0, 0x84d
	.symb	LTIM, "uiRetVal", 2, 0, 0xcd
;  365 |   else
;  366 |      uiRetVal = AMD_Program_Word(uiAddress, uiValue, uiFlashBase);
	.symb	LINE, 366
	mov16	d4,d5				; uiAddress
	mov16	d5,d6				; uiValue
	mov16	d6,d7				; uiFlashBase
	callg	AMD_Program_Word
_173:
;  367 |
;  368 |   return uiRetVal;
;  369 |}
	.symb	LINE, 369
	ret16
	.symb	LTIM, "uiRetVal", 2, 0, 0x4d
	.symb	EFUN
;  370 |
;  371 |unsigned int AMD_Flash_ID( unsigned int uiFlashBase )
;  372 |{
	.symb	LINE, 372
	.symb	TYPE, 271, 'X', 8, #18, 26, 1, #18
	.symb	GFUN, "AMD_Flash_ID", AMD_Flash_ID, #271, 0, 0, 0
	.symb	ALAB, AMD_Flash_ID, #271
AMD_Flash_ID:
	.symb	IDEN, "uiFlashBase", 4, #18, 0, 0x80d
	.symb	TYPE, 273, 'P', #18
	.symb	IDEN, "puiAddress", -1, #273, 131, 0x5
	.symb	IDEN, "uiData", -1, #18, 131, 0x5
	.symb	IDEN, "uiHelp", -1, #18, 131, 0x5
	.symb	SOFF, 0
	.symb	LTIM, "uiFlashBase", 4, 0, 0x8cd
	.symb	LTIM, "puiAddress", -1, 0, 0x45
	.symb	LTIM, "uiData", -1, 0, 0x45
	.symb	LTIM, "uiHelp", -1, 0, 0x45
	.symb	LTIM, "puiAddress", 23, 0, 0xcd
	.symb	LTIM, "puiAddress", 23, 0, 0x4d
	.symb	LTIM, "puiAddress", 23, 0, 0xcd
	.symb	LTIM, "puiAddress", 23, 0, 0x4d
	.symb	LTIM, "puiAddress", 31, 0, 0xcd
	.symb	LTIM, "puiAddress", 31, 0, 0x4d
	.symb	LTIM, "puiAddress", 31, 0, 0xcd
	.symb	LTIM, "uiData", 7, 0, 0xcd
	.symb	LTIM, "uiHelp", 15, 0, 0xcd
	.symb	LTIM, "uiData", 7, 0, 0x4d
	.symb	LTIM, "uiData", 7, 0, 0xcd
	.symb	LTIM, "uiHelp", 15, 0, 0x4d
	.symb	LTIM, "uiHelp", 2, 0, 0xcd
	.symb	LTIM, "uiHelp", 2, 0, 0x4d
	.symb	LTIM, "uiHelp", 2, 0, 0xcd
	.symb	LTIM, "uiData", 7, 0, 0x4d
;  373 |   register unsigned int *puiAddress;
;  374 |   register unsigned int uiData = 0x0;
;  375 |   register unsigned int uiHelp = 0x0;
;  376 |   /* first bus cycle */
;  377 |   puiAddress = (unsigned int *)(SETUP_ADDR+uiFlashBase);
	.symb	LINE, 377
	addi	d15,d4,#5460
	mov16.a	a15,d15
	mov.u	d15,#0xaa			; 11141290
	mov16.aa a7,a15				; puiAddress
;  378 |   *puiAddress = AMDSETUP;
	.symb	LINE, 378
	addih	d15,d15,#0xaa			; 11141290
	st16.w	[a7],d15			; puiAddress
;  379 |   /* second bus cycle */
;  380 |   puiAddress = (unsigned int *)(UNLOCK_ADDR+uiFlashBase);
	.symb	LINE, 380
	addi	d15,d4,#2728
	mov16.a	a7,d15
;  381 |   *puiAddress = AMDUNLOCK;
	.symb	LINE, 381
	mov.u	d15,#0x55			; 5570645
	addih	d15,d15,#0x55			; 5570645
	st16.w	[a7],d15			; puiAddress
;  382 |   /* third bus cycle */
;  383 |   puiAddress = (unsigned int *)(SETUP_ADDR+uiFlashBase);
;  384 |   *puiAddress = AMDREAD_ID;
	.symb	LINE, 384
	mov.u	d15,#0x90			; 9437328
	addih	d15,d15,#0x90			; 9437328
	st16.w	[a15],d15			; puiAddress
;  385 |   puiAddress = (unsigned int *)(uiFlashBase);
	.symb	LINE, 385
	mov16.a	a15,d4				; uiFlashBase
	movh	d15,#0xffff			; -65536
;  386 |   uiData = *puiAddress;
	.symb	LINE, 386
	ld16.w	d7,[a15]
;  387 |   uiHelp = (uiData & 0xffff0000);
	.symb	LINE, 387
	and16	d15,d7
;  388 |   if ((uiData & 0xffff) != (uiHelp>>16))
	.symb	LINE, 388
	mov.u	d6,#65535			; 65535
	and16	d7,d6
	sh	d6,d15,#-16
	jne	d7,d6,_182
	movh	d2,#0xffff			; -65536
;  389 |      return 0;
;  390 |   else
;  391 |      uiData = *(puiAddress+1);
	.symb	LINE, 391
	ld16.w	d7,[a15]4
;  392 |   uiHelp |= (uiData & 0xffff0000)>>16;
	.symb	LINE, 392
	and16	d2,d7
	sh	d2,d2,#-16
	or16	d2,d15				; uiHelp
;  393 |   if ((uiData & 0xffff) != (uiHelp & 0xffff))
	.symb	LINE, 393
	mov.u	d15,#65535			; 65535
	and16	d7,d15
	and16	d15,d2
	jeq	d7,d15,_183
;  394 |      return 0;
	.symb	LINE, 394
_182:
	.symb	LTIM, "uiHelp", 2, 0, 0x4d
	mov16	d2,#0				; 0
	ret16
_183:
	.symb	LTIM, "puiAddress", 31, 0, 0x4d
	.symb	LTIM, "puiAddress", 31, 0, 0xcd
	.symb	LTIM, "uiHelp", 2, 0, 0xcd
;  395 |
;  396 |   *puiAddress = AMDRESET;
	.symb	LINE, 396
	mov.u	d15,#0xf0			; 15728880
	addih	d15,d15,#0xf0			; 15728880
	st16.w	[a15],d15			; puiAddress
;  397 |
;  398 |   return uiHelp;
;  399 |}
	.symb	LINE, 399
_184:
	ret16
	.symb	LTIM, "uiHelp", 2, 0, 0x4d
	.symb	LTIM, "puiAddress", 31, 0, 0x4d
	.symb	LTIM, "uiFlashBase", 4, 0, 0x84d
	.symb	EFUN
;  400 |
;  401 |/* write value at address and wait for success */
;  402 |unsigned int AMD_Program_Word( unsigned int uiAddress, unsigned int uiValue, unsigned int uiFlashBase )
;  403 |{
	.symb	LINE, 403
	.symb	TYPE, 274, 'X', 8, #18, 26, 3, #18, #18, #18
	.symb	GFUN, "AMD_Program_Word", AMD_Program_Word, #274, 0, 0, 0
	.symb	ALAB, AMD_Program_Word, #274
AMD_Program_Word:
	.symb	IDEN, "uiAddress", 4, #18, 0, 0x80d
	.symb	IDEN, "uiValue", 5, #18, 0, 0x80d
	.symb	IDEN, "uiFlashBase", 6, #18, 0, 0x80d
	.symb	IDEN, "uiData", -1, #18, 131, 0x5
	.symb	IDEN, "puiAddress", -1, #273, 131, 0x5
;  404 |   register unsigned int uiData;
;  405 |   volatile register unsigned int *puiAddress;
;  406 |   /* first bus cycle */
;  407 |   puiAddress = (unsigned int *)(SETUP_ADDR+uiFlashBase);
	.symb	LINE, 407
	addi	d15,d6,#5460
	.symb	SOFF, 0
	.symb	LTIM, "uiAddress", 4, 0, 0x8cd
	.symb	LTIM, "uiValue", 5, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 6, 0, 0x8cd
	.symb	LTIM, "uiData", -1, 0, 0x45
	.symb	LTIM, "puiAddress", -1, 0, 0x45
	.symb	LTIM, "puiAddress", 23, 0, 0xcd
	.symb	LTIM, "uiFlashBase", 6, 0, 0x84d
	.symb	LTIM, "puiAddress", 23, 0, 0x4d
	.symb	LTIM, "puiAddress", 23, 0, 0xcd
	.symb	LTIM, "puiAddress", 23, 0, 0x4d
	.symb	LTIM, "puiAddress", 31, 0, 0xcd
	.symb	LTIM, "puiAddress", 31, 0, 0x4d
	.symb	LTIM, "puiAddress", 31, 0, 0xcd
	mov16.a	a15,d15
	mov.u	d15,#0xaa			; 11141290
	mov16.aa a7,a15				; puiAddress
;  408 |   *puiAddress = AMDSETUP ;
	.symb	LINE, 408
	addih	d15,d15,#0xaa			; 11141290
	st16.w	[a7],d15			; puiAddress
;  409 |   /* second bus cycle */
;  410 |   puiAddress = (unsigned int *)(UNLOCK_ADDR+uiFlashBase);
	.symb	LINE, 410
	addi	d6,d6,#2728
	mov16.a	a7,d6
;  411 |   *puiAddress = AMDUNLOCK;
	.symb	LINE, 411
	mov.u	d15,#0x55			; 5570645
	addih	d15,d15,#0x55			; 5570645
	st16.w	[a7],d15			; puiAddress
;  412 |   /* third bus cycle */
;  413 |   puiAddress = (unsigned int *)(SETUP_ADDR+uiFlashBase);
;  414 |   *puiAddress = AMDPROGRAM;
	.symb	LINE, 414
	mov.u	d15,#0xa0			; 10485920
	addih	d15,d15,#0xa0			; 10485920
	st16.w	[a15],d15			; puiAddress
;  415 |   /* fourth bus cycle */
;  416 |   puiAddress = (unsigned int *)uiAddress;
	.symb	LINE, 416
	mov16.a	a15,d4				; uiAddress
	mov.u	d7,#0x20			; 2097184
;  417 |   *puiAddress = uiValue;
	.symb	LINE, 417
	st16.w	[a15],d5			; puiAddress
;  418 |
;  419 |   /* data polling */
;  420 |   do
	.symb	LINE, 420
	addih	d7,d7,#0x20			; 2097184
	mov.u	d15,#0xf0			; 15728880
	addih	d15,d15,#0xf0			; 15728880
_192:
	.symb	LTIM, "uiData", 6, 0, 0xcd
	.symb	LTIM, "uiAddress", 4, 0, 0x84d
	.symb	LTIM, "uiData", 6, 0, 0x4d
	.symb	LTIM, "uiData", 7, 0, 0xcd
	.symb	LTIM, "uiData", 7, 0, 0x4d
	mov.u	d4,#0x80			; 8388736
;  421 |      {
;  422 |      /* read value */
;  423 |      uiData = *puiAddress;
	.symb	LINE, 423
	ld16.w	d6,[a15]
;  424 |      /* check data ready */
;  425 |      if ((uiData & DQ7) == (uiValue & DQ7))
	.symb	LINE, 425
	addih	d4,d4,#0x80			; 8388736
	and	d3,d6,d4
	mov.u	d4,#0x80			; 8388736
	addih	d4,d4,#0x80			; 8388736
	and16	d4,d5
	jeq	d3,d4,_193
;  426 |         {
;  427 |         *puiAddress = AMDRESET;
;  428 |         return SUCCESS;
;  429 |         }
;  430 |      /* check of time out */
;  431 |      if ((uiData & DQ5) == DQ5)
	.symb	LINE, 431
	mov.u	d3,#0x20			; 2097184
	addih	d3,d3,#0x20			; 2097184
	and16	d3,d6
	jne	d3,d7,_195
	mov.u	d6,#0x80			; 8388736
;  432 |         {
;  433 |         uiData = *puiAddress;
	.symb	LINE, 433
	ld16.w	d7,[a15]
;  434 |         if ((uiData & DQ7) == (uiValue & DQ7))
	.symb	LINE, 434
	addih	d6,d6,#0x80			; 8388736
	and16	d7,d6
	jne	d7,d4,_194
;  435 |            {
;  436 |            *puiAddress = AMDRESET;
	.symb	LINE, 436
_193:
	nop
	st16.w	[a15],d15			; puiAddress
;  437 |            return SUCCESS;
	.symb	LINE, 437
	j	_196
;  438 |            }
	.symb	LINE, 438
_194:
	.symb	LTIM, "puiAddress", 31, 0, 0x4d
	.symb	LTIM, "puiAddress", 31, 0, 0xcd
	mov16	d2,#1				; 1
;  439 |         else
;  440 |            {
;  441 |            *puiAddress = AMDRESET;
	.symb	LINE, 441
	st16.w	[a15],d15			; puiAddress
;  442 |            return FAILURE;
	.symb	LINE, 442
	ret16
;  443 |            }
;  444 |         }
	.symb	LINE, 444
_195:
	.symb	LTIM, "uiValue", 5, 0, 0x84d
	.symb	LTIM, "uiValue", 5, 0, 0x8cd
	.symb	LTIM, "puiAddress", 31, 0, 0x4d
	.symb	LTIM, "puiAddress", 31, 0, 0xcd
	.symb	LTIM, "uiData", 6, 0, 0xcd
	.symb	LTIM, "uiData", 6, 0, 0x4d
;  445 |      }
;  446 |   while ((uiData & DQ5) != DQ5);
	.symb	LINE, 446
	mov.u	d4,#0x20			; 2097184
	addih	d4,d4,#0x20			; 2097184
	and16	d6,d4
	jne	d6,d7,_192
;  447 |return SUCCESS;
	.symb	LINE, 447
_196:
	mov16	d2,#0				; 0
;  448 |}
	.symb	LINE, 448
_197:
	ret16
	.symb	LTIM, "puiAddress", 31, 0, 0x4d
	.symb	LTIM, "uiValue", 5, 0, 0x84d
	.symb	EFUN
;  449 |
;  450 |/* chip erase */
;  451 |unsigned int AMD_Chip_Erase( unsigned int uiFlashBase )
;  452 |{
	.symb	LINE, 452
	.symb	TYPE, 275, 'X', 8, #18, 26, 1, #18
	.symb	GFUN, "AMD_Chip_Erase", AMD_Chip_Erase, #275, 0, 0, 0
	.symb	ALAB, AMD_Chip_Erase, #275
AMD_Chip_Erase:
	.symb	IDEN, "uiFlashBase", 4, #18, 0, 0x80d
	.symb	IDEN, "puiAddress", -1, #273, 131, 0x5
	.symb	IDEN, "uiData", -1, #18, 131, 0x5
	addi	d7,d4,#5460
	.symb	SOFF, 0
	.symb	LTIM, "uiFlashBase", 4, 0, 0x8cd
	.symb	LTIM, "puiAddress", -1, 0, 0x45
	.symb	LTIM, "uiData", -1, 0, 0x45
	.symb	LTIM, "uiData", 15, 0, 0xcd
	.symb	LTIM, "puiAddress", 23, 0, 0xcd
	.symb	LTIM, "puiAddress", 23, 0, 0x4d
	.symb	LTIM, "puiAddress", 22, 0, 0xcd
	.symb	LTIM, "puiAddress", 22, 0, 0x4d
	.symb	LTIM, "puiAddress", 22, 0, 0xcd
	.symb	LTIM, "puiAddress", 22, 0, 0x4d
	.symb	LTIM, "puiAddress", 22, 0, 0xcd
	.symb	LTIM, "puiAddress", 22, 0, 0x4d
	.symb	LTIM, "puiAddress", 23, 0, 0xcd
	.symb	LTIM, "puiAddress", 23, 0, 0x4d
	.symb	LTIM, "puiAddress", 31, 0, 0xcd
	.symb	LTIM, "puiAddress", 31, 0, 0x4d
	.symb	LTIM, "puiAddress", 31, 0, 0xcd
	mov16.a	a15,d7
;  453 |   register unsigned int *puiAddress;
;  454 |   register unsigned int uiData = 0x0;
	.symb	LINE, 454
	mov16	d15,#0				; 0
;  455 |   /* first bus cycle */
;  456 |   puiAddress = (unsigned int *)(SETUP_ADDR+uiFlashBase);
	.symb	LINE, 456
	mov16.aa a7,a15				; puiAddress
;  457 |   *puiAddress = AMDSETUP;
	.symb	LINE, 457
	mov.u	d6,#0xaa			; 11141290
	addih	d6,d6,#0xaa			; 11141290
	st16.w	[a7],d6				; puiAddress
;  458 |   /* second bus cycle */
;  459 |   puiAddress = (unsigned int *)(UNLOCK_ADDR+uiFlashBase);
	.symb	LINE, 459
	addi	d7,d4,#2728
	mov16.a	a7,d7
	mov.u	d5,#0x55			; 5570645
	mov16.aa a6,a7				; puiAddress
;  460 |   *puiAddress = AMDUNLOCK;
	.symb	LINE, 460
	addih	d5,d5,#0x55			; 5570645
	st16.w	[a6],d5				; puiAddress
	mov.u	d7,#0x80			; 8388736
;  461 |   /* third bus cycle */
;  462 |   puiAddress = (unsigned int *)(SETUP_ADDR+uiFlashBase);
	.symb	LINE, 462
	mov16.aa a6,a15				; puiAddress
;  463 |   *puiAddress = AMDCHIP_ERASE1;
	.symb	LINE, 463
	addih	d7,d7,#0x80			; 8388736
	st16.w	[a6],d7				; puiAddress
;  464 |   /* fourth bus cycle */
;  465 |   puiAddress = (unsigned int *)(SETUP_ADDR+uiFlashBase);
	.symb	LINE, 465
	mov16.aa a6,a15				; puiAddress
;  466 |   *puiAddress = AMDSETUP;
	.symb	LINE, 466
	st16.w	[a6],d6				; puiAddress
	mov.u	d6,#0x10			; 1048592
;  467 |   /* fifth bus cycle */
;  468 |   puiAddress = (unsigned int *)(UNLOCK_ADDR+uiFlashBase);
;  469 |   *puiAddress = AMDUNLOCK;
	.symb	LINE, 469
	st16.w	[a7],d5				; puiAddress
;  470 |   /* sixth bus cycle */
;  471 |   puiAddress = (unsigned int *)(SETUP_ADDR+uiFlashBase);
;  472 |   *puiAddress = AMDCHIP_ERASE2;
	.symb	LINE, 472
	addih	d6,d6,#0x10			; 1048592
	st16.w	[a15],d6			; puiAddress
;  473 |   /* Polling while DQ7 == LOW */
;  474 |   puiAddress = (unsigned int *)uiFlashBase;
	.symb	LINE, 474
	mov16.a	a15,d4				; uiFlashBase
;  475 |   while ((uiData & DQ7) != DQ7) 
	.symb	LINE, 475
	j	_199
_198:
	.symb	LTIM, "uiData", 15, 0, 0x4d
	.symb	LTIM, "uiData", 15, 0, 0xcd
;  476 |      {
;  477 |      uiData = *puiAddress;
	.symb	LINE, 477
	nop
	ld16.w	d15,[a15]
	.symb	LINE, 475
_199:
	.symb	LTIM, "uiData", 15, 0, 0x4d
	mov.u	d6,#0x80			; 8388736
	addih	d6,d6,#0x80			; 8388736
	and16	d15,d6
	jne	d15,d7,_198
;  478 |      }
;  479 |   *puiAddress = AMDRESET;
	.symb	LINE, 479
	mov.u	d15,#0xf0			; 15728880
	addih	d15,d15,#0xf0			; 15728880
	st16.w	[a15],d15			; puiAddress
;  480 |
;  481 |   return SUCCESS;
	.symb	LINE, 481
	mov16	d2,#0				; 0
;  482 |}
	.symb	LINE, 482
	ret16
	.symb	LTIM, "puiAddress", 31, 0, 0x4d
	.symb	LTIM, "uiFlashBase", 4, 0, 0x84d
	.symb	EFUN
;  483 |
;  484 |unsigned int Intel_Flash_ID( unsigned int uiFlashBase )
;  485 |{
	.symb	LINE, 485
	.symb	TYPE, 276, 'X', 8, #18, 26, 1, #18
	.symb	GFUN, "Intel_Flash_ID", Intel_Flash_ID, #276, 0, 0, 0
	.symb	ALAB, Intel_Flash_ID, #276
Intel_Flash_ID:
	.symb	IDEN, "uiFlashBase", 4, #18, 0, 0x80d
	.symb	IDEN, "puiAddress", -1, #273, 131, 0x5
	.symb	IDEN, "uiData", -1, #18, 131, 0x5
	.symb	IDEN, "uiHelp", -1, #18, 131, 0x5
	mov.u	d6,#65535			; 65535
	.symb	SOFF, 0
	.symb	LTIM, "uiFlashBase", 4, 0, 0x8cd
	.symb	LTIM, "puiAddress", -1, 0, 0x45
	.symb	LTIM, "uiData", -1, 0, 0x45
	.symb	LTIM, "uiHelp", -1, 0, 0x45
	.symb	LTIM, "puiAddress", 31, 0, 0xcd
	.symb	LTIM, "uiData", 7, 0, 0xcd
	.symb	LTIM, "uiHelp", 15, 0, 0xcd
	.symb	LTIM, "uiData", 7, 0, 0x4d
	.symb	LTIM, "uiData", 7, 0, 0xcd
	.symb	LTIM, "uiHelp", 15, 0, 0x4d
	.symb	LTIM, "uiHelp", 2, 0, 0xcd
	.symb	LTIM, "uiHelp", 2, 0, 0x4d
	.symb	LTIM, "uiHelp", 2, 0, 0xcd
	.symb	LTIM, "uiData", 7, 0, 0x4d
;  486 |   volatile unsigned int *puiAddress;
;  487 |   unsigned int uiData = 0x0;
;  488 |   unsigned int uiHelp = 0x0;
;  489 |
;  490 |   /* first bus cycle */
;  491 |   puiAddress = (unsigned int *)(uiFlashBase);
	.symb	LINE, 491
	mov16.a	a15,d4				; uiFlashBase
;  492 |   *puiAddress = INTELREAD_ID;
	.symb	LINE, 492
	mov.u	d15,#0x90			; 9437328
	addih	d15,d15,#0x90			; 9437328
	st16.w	[a15],d15			; puiAddress
	movh	d15,#0xffff			; -65536
;  493 |
;  494 |   uiData = *puiAddress;
	.symb	LINE, 494
	ld16.w	d7,[a15]
;  495 |   uiHelp = (uiData & 0xffff0000);
	.symb	LINE, 495
	and16	d15,d7
;  496 |   if ((uiData & 0xffff) != (uiHelp>>16))
	.symb	LINE, 496
	and16	d7,d6
	sh	d6,d15,#-16
	jne	d7,d6,_208
	movh	d2,#0xffff			; -65536
;  497 |      return 0;
;  498 |   else
;  499 |      uiData = *(puiAddress+1);
	.symb	LINE, 499
	ld16.w	d7,[a15]4
;  500 |   uiHelp |= (uiData & 0xffff0000)>>16;
	.symb	LINE, 500
	and16	d2,d7
	sh	d2,d2,#-16
	or16	d2,d15				; uiHelp
;  501 |   if ((uiData & 0xffff) != (uiHelp & 0xffff))
	.symb	LINE, 501
	mov.u	d15,#65535			; 65535
	and16	d7,d15
	and16	d15,d2
	jeq	d7,d15,_209
;  502 |      return 0;
	.symb	LINE, 502
_208:
	.symb	LTIM, "uiHelp", 2, 0, 0x4d
	mov16	d2,#0				; 0
	ret16
_209:
	.symb	LTIM, "puiAddress", 31, 0, 0x4d
	.symb	LTIM, "puiAddress", 31, 0, 0xcd
	.symb	LTIM, "uiHelp", 2, 0, 0xcd
;  503 |
;  504 |   *puiAddress = INTELREAD_ARRAY;
	.symb	LINE, 504
	mov.u	d15,#0xff			; 16711935
	addih	d15,d15,#0xff			; 16711935
	st16.w	[a15],d15			; puiAddress
;  505 |   return uiHelp;
;  506 |}
	.symb	LINE, 506
_210:
	ret16
	.symb	LTIM, "uiHelp", 2, 0, 0x4d
	.symb	LTIM, "puiAddress", 31, 0, 0x4d
	.symb	LTIM, "uiFlashBase", 4, 0, 0x84d
	.symb	EFUN
;  507 |
;  508 |unsigned int Intel_Chip_Erase(unsigned int uiID, unsigned int uiFlashBase)
;  509 |{
	.symb	LINE, 509
	.symb	TYPE, 277, 'X', 8, #18, 26, 2, #18, #18
	.symb	GFUN, "Intel_Chip_Erase", Intel_Chip_Erase, #277, 0, 0, 0
	.symb	ALAB, Intel_Chip_Erase, #277
Intel_Chip_Erase:
	.symb	IDEN, "uiID", 4, #18, 0, 0x80d
	.symb	IDEN, "uiFlashBase", 5, #18, 0, 0x80d
	.symb	IDEN, "puiAddress", -1, #273, 131, 0x5
	.symb	IDEN, "uiCnt", -1, #18, 131, 0x5
	.symb	IDEN, "uiSectorNumbers", -1, #18, 131, 0x5
	.symb	IDEN, "uiTop", -1, #18, 131, 0x5
	.symb	IDEN, "uiStatus", -1, #18, 131, 0x5
	mov.u	d15,#65535			; 65535
	.symb	SOFF, 0
	.symb	LTIM, "uiID", 4, 0, 0x8cd
	.symb	LTIM, "uiFlashBase", 5, 0, 0x8cd
	.symb	LTIM, "puiAddress", -1, 0, 0x45
	.symb	LTIM, "uiCnt", -1, 0, 0x45
	.symb	LTIM, "uiSectorNumbers", -1, 0, 0x45
	.symb	LTIM, "uiTop", -1, 0, 0x45
	.symb	LTIM, "uiStatus", -1, 0, 0x45
	.symb	LTIM, "uiTop", 7, 0, 0xcd
;  510 |   volatile unsigned int *puiAddress;
;  511 |   unsigned int uiCnt, uiSectorNumbers, uiTop;
;  512 |   unsigned int uiStatus;
;  513 |
;  514 |   uiTop = 0;
	.symb	LINE, 514
	mov16	d7,#0				; 0
;  515 |
;  516 |   switch(uiID & 0xFFFF)
	.symb	LINE, 516
	and16	d15,d4
	addih	d15,d15,#65535
	addi	d15,d15,#30476
	jeq	d15,#-3,_231			; case 35057
	jeq	d15,#-2,_232			; case 35058
	jeq	d15,#-1,_229			; case 35059
	jeq	d15,#0,_230			; case 35060
	j	_236				; default
;  517 |      {
;  518 |      case DT28F800F3T_ID:
;  519 |         uiTop = 1;
;  520 |      case DT28F800F3B_ID:
;  521 |         uiSectorNumbers = 23;
;  522 |         break;
;  523 |      case DT28F160F3T_ID:
	.symb	LINE, 523
_229:
	.symb	LTIM, "uiTop", 7, 0, 0x4d
	.symb	LTIM, "uiTop", 7, 0, 0xcd
;  524 |         uiTop = 1;
	.symb	LINE, 524
	mov16	d7,#1				; 1
;  525 |      case DT28F160F3B_ID:
	.symb	LINE, 525
_230:
	.symb	LTIM, "uiSectorNumbers", 15, 0, 0xcd
;  526 |         uiSectorNumbers = 39;
	.symb	LINE, 526
	mov16	d15,#39				; 39
;  527 |         break;
	.symb	LINE, 527
	j	_233
	.symb	LINE, 518
_231:
	.symb	LTIM, "uiTop", 7, 0, 0x4d
	.symb	LTIM, "uiTop", 7, 0, 0xcd
	.symb	LINE, 519
	mov16	d7,#1				; 1
	.symb	LINE, 520
_232:
	.symb	LTIM, "uiSectorNumbers", 15, 0, 0x4d
	.symb	LTIM, "uiSectorNumbers", 15, 0, 0xcd
	.symb	LINE, 521
	mov16	d15,#23				; 23
;  528 |      default:
;  529 |         return 1;
;  530 |      }
	.symb	LINE, 530
_233:
	.symb	LTIM, "puiAddress", 31, 0, 0xcd
	.symb	LTIM, "uiCnt", 6, 0, 0xcd
;  531 |
;  532 |   puiAddress = (unsigned int *)(uiFlashBase);
	.symb	LINE, 532
	mov16.a	a15,d5				; uiFlashBase
;  533 |
;  534 |   for (uiCnt=0; uiCnt<uiSectorNumbers; uiCnt++)
	.symb	LINE, 534
	mov16	d6,#0				; 0
	j	_243
_234:
	.symb	LTIM, "uiFlashBase", 5, 0, 0x84d
	.symb	LTIM, "uiID", 4, 0, 0x84d
;  535 |      {
;  536 |      *puiAddress = INTELBLK_ERASE;
	.symb	LINE, 536
	mov.u	d5,#0x20			; 2097184
	addih	d5,d5,#0x20			; 2097184
	st16.w	[a15],d5			; puiAddress
;  537 |      *puiAddress = INTELRESUME;
	.symb	LINE, 537
	mov.u	d5,#0xd0			; 13631696
	addih	d5,d5,#0xd0			; 13631696
	st16.w	[a15],d5			; puiAddress
;  538 |      do
	.symb	LINE, 538
	mov.u	d4,#0x80			; 8388736
	addih	d4,d4,#0x80			; 8388736
_235:
	.symb	LTIM, "uiStatus", 5, 0, 0xcd
	.symb	LTIM, "uiStatus", 5, 0, 0x4d
	mov.u	d3,#0x80			; 8388736
;  539 |         {
;  540 |         uiStatus = *puiAddress;
	.symb	LINE, 540
	ld16.w	d5,[a15]
;  541 |         }
;  542 |      while ((uiStatus & STAT_WSMS) != STAT_WSMS);
	.symb	LINE, 542
	addih	d3,d3,#0x80			; 8388736
	and16	d3,d5
	jne	d3,d4,_235
;  543 |      if (uiStatus & STAT_ES)
	.symb	LINE, 543
	mov.u	d4,#0x20			; 2097184
	addih	d4,d4,#0x20			; 2097184
	and16	d5,d4
	jeq	d5,#0,_237
;  544 |         return FAILURE;
	.symb	LINE, 544
_236:
	mov16	d2,#1				; 1
	ret16
_237:
	.symb	LTIM, "uiTop", 7, 0, 0x4d
	.symb	LTIM, "uiTop", 7, 0, 0xcd
	.symb	LTIM, "uiSectorNumbers", 15, 0, 0x4d
	.symb	LTIM, "uiSectorNumbers", 15, 0, 0xcd
	.symb	LTIM, "puiAddress", 31, 0, 0x4d
	.symb	LTIM, "puiAddress", 31, 0, 0xcd
	.symb	LTIM, "uiCnt", 6, 0, 0x4d
	.symb	LTIM, "uiCnt", 6, 0, 0xcd
;  545 |      if (uiTop)
	.symb	LINE, 545
	jeq	d7,#0,_238			; uiTop
;  546 |         {
;  547 |         if (uiCnt<(uiSectorNumbers-8))
	.symb	LINE, 547
	addi	d5,d15,#-8
	jge.u	d6,d5,_239
;  548 |            puiAddress += 0x2000;
	.symb	LINE, 548
	j	_241
;  549 |         else
;  550 |            puiAddress += 0x400;
;  551 |         }
	.symb	LINE, 551
_238:
;  552 |      else
;  553 |         {
;  554 |         if (uiCnt<8)
	.symb	LINE, 554
	jge.u	d6,#8,_241
;  555 |            puiAddress += 0x400;
	.symb	LINE, 555
_239:
	.symb	LTIM, "puiAddress", 31, 0, 0x4d
	.symb	LTIM, "puiAddress", 31, 0, 0xcd
	.symb	LTIM, "puiAddress", 31, 0, 0x4d
	.symb	LTIM, "puiAddress", 31, 0, 0xcd
	nop
	lea	a15,[a15]4096			; puiAddress
	j	_242
_241:
	.symb	LTIM, "puiAddress", 31, 0, 0x4d
	.symb	LTIM, "puiAddress", 31, 0, 0xcd
	.symb	LTIM, "puiAddress", 31, 0, 0x4d
	.symb	LTIM, "puiAddress", 31, 0, 0xcd
;  556 |         else
;  557 |            puiAddress += 0x2000;
	.symb	LINE, 557
	mov.u	d5,#32768			; 32768
	addsc.a	a15,a15,d5,#0			; puiAddress
;  558 |         }
	.symb	LINE, 558
_242:
	.symb	LTIM, "uiCnt", 6, 0, 0x4d
	.symb	LTIM, "uiCnt", 6, 0, 0xcd
	.symb	LTIM, "uiCnt", 6, 0, 0x4d
	.symb	LTIM, "uiCnt", 6, 0, 0xcd
	.symb	LINE, 534
	add16	d6,#1				; uiCnt
_243:
	.symb	LTIM, "uiSectorNumbers", 15, 0, 0x4d
	jlt.u	d6,d15,_234
;  559 |      }
;  560 |   *puiAddress = INTELREAD_ARRAY;
	.symb	LINE, 560
	mov.u	d15,#0xff			; 16711935
	addih	d15,d15,#0xff			; 16711935
	st16.w	[a15],d15			; puiAddress
;  561 |   return SUCCESS;
	.symb	LINE, 561
	mov16	d2,#0				; 0
;  562 |}
	.symb	LINE, 562
_244:
	ret16
	.symb	LTIM, "puiAddress", 31, 0, 0x4d
	.symb	LTIM, "uiCnt", 6, 0, 0x4d
	.symb	LTIM, "uiTop", 7, 0, 0x4d
	.symb	EFUN
;  563 |
;  564 |unsigned int Intel_Program_Word( unsigned int uiAddress, unsigned int uiValue )
;  565 |{
	.symb	LINE, 565
	.symb	TYPE, 278, 'X', 8, #18, 26, 2, #18, #18
	.symb	GFUN, "Intel_Program_Word", Intel_Program_Word, #278, 0, 0, 0
	.symb	ALAB, Intel_Program_Word, #278
Intel_Program_Word:
	.symb	IDEN, "uiAddress", 4, #18, 0, 0x80d
	.symb	IDEN, "uiValue", 5, #18, 0, 0x80d
	.symb	IDEN, "puiAddress", -1, #273, 131, 0x5
	.symb	IDEN, "uiStatus", -1, #18, 131, 0x5
	mov.u	d15,#0x40			; 4194368
	.symb	SOFF, 0
	.symb	LTIM, "uiAddress", 4, 0, 0x8cd
	.symb	LTIM, "uiValue", 5, 0, 0x8cd
	.symb	LTIM, "puiAddress", -1, 0, 0x45
	.symb	LTIM, "uiStatus", -1, 0, 0x45
	.symb	LTIM, "puiAddress", 31, 0, 0xcd
;  566 |   volatile unsigned int *puiAddress;
;  567 |   unsigned int uiStatus;
;  568 |
;  569 |   puiAddress = (unsigned int *)(uiAddress);
	.symb	LINE, 569
	mov16.a	a15,d4				; uiAddress
;  570 |
;  571 |   *puiAddress = INTELPROG_STD;
	.symb	LINE, 571
	addih	d15,d15,#0x40			; 4194368
	st16.w	[a15],d15			; puiAddress
	mov.u	d15,#0x80			; 8388736
;  572 |   *puiAddress = uiValue;
	.symb	LINE, 572
	st16.w	[a15],d5			; puiAddress
;  573 |   do
	.symb	LINE, 573
	addih	d15,d15,#0x80			; 8388736
_245:
	.symb	LTIM, "uiStatus", 7, 0, 0xcd
	.symb	LTIM, "uiStatus", 7, 0, 0x4d
	mov.u	d6,#0x80			; 8388736
;  574 |      {
;  575 |      uiStatus = *puiAddress;
	.symb	LINE, 575
	ld16.w	d7,[a15]
;  576 |      }
;  577 |   while ((uiStatus & STAT_WSMS) != STAT_WSMS);
	.symb	LINE, 577
	addih	d6,d6,#0x80			; 8388736
	and16	d6,d7
	jne	d6,d15,_245
;  578 |
;  579 |   if (uiStatus & STAT_PS)
	.symb	LINE, 579
	mov.u	d6,#0x10			; 1048592
	addih	d6,d6,#0x10			; 1048592
	and16	d7,d6
	jeq	d7,#0,_248
;  580 |      {
;  581 |      *puiAddress = INTELPROG_ALT;
	.symb	LINE, 581
	mov.u	d7,#0x10			; 1048592
	addih	d7,d7,#0x10			; 1048592
	st16.w	[a15],d7			; puiAddress
;  582 |      *puiAddress = uiValue;
	.symb	LINE, 582
	st16.w	[a15],d5			; puiAddress
;  583 |      do
	.symb	LINE, 583
_246:
	.symb	LTIM, "uiStatus", 7, 0, 0xcd
	mov.u	d6,#0x80			; 8388736
;  584 |         {
;  585 |         uiStatus = *puiAddress;
	.symb	LINE, 585
	ld16.w	d7,[a15]
;  586 |         }
;  587 |      while ((uiStatus & STAT_WSMS) != STAT_WSMS);
	.symb	LINE, 587
	addih	d6,d6,#0x80			; 8388736
	and16	d6,d7
	jne	d6,d15,_246
;  588 |
;  589 |      if (uiStatus & STAT_PS)
	.symb	LINE, 589
	mov.u	d15,#0x10			; 1048592
	addih	d15,d15,#0x10			; 1048592
	and16	d15,d7
	jeq	d15,#0,_248
;  590 |         return FAILURE;
	.symb	LINE, 590
	mov16	d2,#1				; 1
	ret16
;  591 |      }
	.symb	LINE, 591
_248:
	.symb	LTIM, "puiAddress", 31, 0, 0x4d
	.symb	LTIM, "puiAddress", 31, 0, 0xcd
;  592 |   *puiAddress = INTELREAD_ARRAY;
	.symb	LINE, 592
	mov.u	d15,#0xff			; 16711935
	addih	d15,d15,#0xff			; 16711935
	st16.w	[a15],d15			; puiAddress
;  593 |   return SUCCESS;
	.symb	LINE, 593
	mov16	d2,#0				; 0
;  594 |}
	.symb	LINE, 594
_249:
	ret16
	.symb	LTIM, "puiAddress", 31, 0, 0x4d
	.symb	LTIM, "uiStatus", 7, 0, 0x4d
	.symb	LTIM, "uiValue", 5, 0, 0x84d
	.symb	LTIM, "uiAddress", 4, 0, 0x84d
	.symb	EFUN
	.symb	ENDF
	.sdecl	"fardata.flash",DATA,INIT
	.sect	"fardata.flash"
	.align	4
_18:
	.ascii	"TC58FVT160FT"
	.byte	0x00
	.align	2
_13:
	.ascii	"AM29LV800TB"
	.byte	0x00
_10:
	.ascii	"AM29LV400BB"
	.byte	0x00
_28:
	.ascii	"Determined SRAM is of %dKB size"
	.byte	0x00
_7:
	.ascii	"TC58FVT400FT"
	.byte	0x00
	.align	2
_27:
	.ascii	"Determined SRAM is of %dMB size"
	.byte	0x00
_20:
	.ascii	"AM29LV160TB"
	.byte	0x00
	.symb	TYPE, 280, 'P', #2
	.symb	TYPE, 281, 'X', 8, #280, 26, 2, #258, #258
	.symb	ALAB, strcat, #281
_15:
	.ascii	"AM29BL802C"
	.byte	0x00
	.symb	TYPE, 282, 'Z', #2, 79
	.symb	TYPE, 284, 'Z', #282, 6
	.symb	IDEN, "szStatusMessage", szStatusMessage, #284, 129, 0x0
	.symb	ALAB, szStatusMessage, #284
	.sdecl	"farbss.flash",DATA,CLEAR
	.sect	"farbss.flash"
	.align	4
szStatusMessage:
	.space	560
	.sect	"fardata.flash"
	.align	2
_5:
	.ascii	"AM29LV200TB"
	.byte	0x00
_33:
	.ascii	"Programming flash device..."
	.byte	0x00
_32:
	.ascii	"completed"
	.byte	0x00
_19:
	.ascii	"TC58FVB160FT"
	.byte	0x00
	.align	2
_17:
	.ascii	"DT28F800F3B"
	.byte	0x00
_31:
	.ascii	"Erasing flash device..."
	.byte	0x00
_16:
	.ascii	"DT28F800F3T"
	.byte	0x00
_8:
	.ascii	"TC58FVB400FT"
	.byte	0x00
	.align	2
_35:
	.ascii	"Failed to verify at address %8.8X"
	.byte	0x00
	.symb	TYPE, 286, 'X', 8, #280, 26, 2, #258, #258
	.symb	ALAB, strcpy, #286
_3:
	.ascii	"FLASH Programmer,  Version 1.0.2,  9-Jul-2002"
	.byte	0x00
_30:
	.ascii	"Determined flash is of %dKB size, type is %s"
	.byte	0x00
	.align	2
_11:
	.ascii	"TC58FVT800FT"
	.byte	0x00
	.align	2
_29:
	.ascii	"Determined flash is of %dMB size, type is %s"
	.byte	0x00
	.align	2
_34:
	.ascii	"Verifying flash device..."
	.byte	0x00
	.symb	TYPE, 287, 'X', 8, #16, 26, 3, #258, #258, #1
	.symb	ALAB, sprintf, #287
_9:
	.ascii	"AM29LV400TB"
	.byte	0x00
_23:
	.ascii	"DT28F160F3B"
	.byte	0x00
_21:
	.ascii	"AM29LV160BB"
	.byte	0x00
_25:
	.ascii	"MBM29DL323TE"
	.byte	0x00
	.align	2
_22:
	.ascii	"AM29BL162C"
	.byte	0x00
	.align	2
_6:
	.ascii	"AM29LV200BB"
	.byte	0x00
_24:
	.ascii	"DT28F160F3T"
	.byte	0x00
_12:
	.ascii	"TC58FVB800FT"
	.byte	0x00
	.align	2
_4:
	.ascii	"Unknown flash manufacturer ID [%X]"
	.byte	0x00
	.align	2
_36:
	.ascii	"Flash programming completed successfully."
	.byte	0x00
_26:
	.ascii	"Unknown / Unsupported flash size"
	.byte	0x00
	.align	2
_14:
	.ascii	"AM29LV800BB"
	.byte	0x00
	.align	4
	.global	AMD_Chip_Erase
	.global	AMD_Flash_ID
	.global	AMD_Program_Word
	.global	Chip_Erase
	.global	Intel_Chip_Erase
	.global	Intel_Flash_ID
	.global	Intel_Program_Word
	.global	Program_Word
	.global	Read_ID
	.global	main
	.global	szStatusMessage
	.extern	_START
	.extern	(DATA) _lc_ub_xvwbuffer
	.extern	(DATA) _lc_ue_xvwbuffer
	.extern	(CODE) sprintf
	.extern	(CODE) strcat
	.extern	(CODE) strcpy
	.calls	"Chip_Erase", "AMD_Chip_Erase"
	.calls	"Chip_Erase", "Intel_Chip_Erase"
	.calls	"Program_Word", "AMD_Program_Word"
	.calls	"Program_Word", "Intel_Program_Word"
	.calls	"Read_ID", "AMD_Flash_ID"
	.calls	"Read_ID", "Intel_Flash_ID"
	.calls	"main", "Chip_Erase"
	.calls	"main", "Program_Word"
	.calls	"main", "Read_ID"
	.calls	"main", "sprintf"
