ECHO OFF
ECHO INSTALL PROCEDURE FOR MONITOR-51  V2.9
ECHO COPYRIGHT KEIL ELEKTRONIK GmbH 1988-2000
ECHO .
REM Syntax Check
IF %4A == PROMCHECKA GOTO SYNTAX1_OK
IF %4A == promcheckA GOTO SYNTAX1_OK
IF %4A == BANKA GOTO SYNTAX1_OK
IF %4A == bankA GOTO SYNTAX1_OK
IF NOT %4A == A GOTO USAGE
:SYNTAX1_OK
IF %5A == PROMCHECKA GOTO SYNTAX_OK
IF %5A == promcheckA GOTO SYNTAX_OK
IF %5A == BANKA GOTO SYNTAX_OK
IF %5A == bankA GOTO SYNTAX_OK
IF NOT %5A == A GOTO USAGE
:SYNTAX_OK
IF %1A == A GOTO USAGE
IF %1 == 0  GOTO SERIAL0
IF %1 == 1  GOTO SERIAL1
IF %1 == 2  GOTO SERIAL2
IF %1 == 3  GOTO SERIAL3
IF %1 == 4  GOTO SERIAL4
IF %1 == 5  GOTO SERIAL5
IF %1 == 6  GOTO SERIAL6
IF %1 == 7  GOTO SERIAL7
IF %1 == 8  GOTO SERIAL8
IF %1 == 9  GOTO SERIAL9
IF %1 == 10 GOTO SERIAL10
IF %1 == 11 GOTO SERIAL11
IF %1 == 12 GOTO SERIAL12
GOTO USAGE
:SERIAL0
ECHO      USING TIMER1 FOR GENERATING SERIAL CLOCK 
ECHO      BAUDRATE: 9600 bps   at CPU CLOCK FREQUENCY 11.059 MHz
GOTO SERIALOK
:SERIAL1
ECHO      USING INTERNAL BAUDRATE GENERATOR (only valid for 80515, 80517)
ECHO      BAUDRATE: 9600 bps   at CPU CLOCK FREQUENCY 12.000 MHz
GOTO SERIALOK
:SERIAL2
ECHO      USING TIMER 2 FOR GENERATING SERIAL CLOCK (8052 AND COMPATIBLES)
ECHO      BAUDRATE: 9600 bps   at CPU CLOCK FREQUENCY 12.000 MHz
GOTO SERIALOK
:SERIAL3
ECHO      USING SERIAL INTERFACE 1 (only valid for 80517)
ECHO      BAUDRATE: 9600 bps   at CPU CLOCK FREQUENCY 12.000 MHz
GOTO SERIALOK
:SERIAL4
ECHO      USING TIMER 2 FOR GENERATING SERIAL CLOCK
ECHO      ONLY FOR DALLAS 80C320/520/530 AND AMD DERIVATIVES WITH 2 DPTR's
ECHO      BAUDRATE: 9600 bps   at CPU CLOCK FREQUENCY 12.000 MHz
GOTO SERIALOK
:SERIAL5
ECHO      USING SECOND SERIAL INTERFACE OF DALLAS 80C320/520/530 WITH 
ECHO      TIMER 1 FOR GENERATING SERIAL CLOCK
ECHO      BAUDRATE: 9600 bps   at CPU CLOCK FREQUENCY 12.000 MHz
GOTO SERIALOK
:SERIAL6
ECHO      USING EXTERNAL UART 16450/16550 
ECHO      BAUDRATE: 9600 bps at UART CLOCK FREQUENCY 3.686400 MHz
GOTO SERIALOK
:SERIAL7
ECHO      USING TIMER 1 FOR GENERATING SERIAL CLOCK
ECHO      BAUDRATE IS SELF ADJUSTING
GOTO SERIALOK
:SERIAL8
ECHO      USING TIMER 2 FOR GENERATING SERIAL CLOCK (8052 AND COMPATIBLES)
ECHO      BAUDRATE IS SELF ADJUSTING
GOTO SERIALOK
:SERIAL9
ECHO      USING INTERNAL BAUDRATE GENERATOR (80515A, 80517A, 505, 515 ...)
ECHO      BAUDRATE IS SELF ADJUSTING
GOTO SERIALOK
:SERIAL10
ECHO      USING SERIAL INTERFACE 1 AND INTERNAL BAUDRATE GENERATOR (80517(A))
ECHO      BAUDRATE IS SELF ADJUSTING
GOTO SERIALOK
:SERIAL11
ECHO      USING TIMER 2 FOR GENERATING SERIAL CLOCK
ECHO      ONLY FOR DALLAS 80C320/520/530 AND AMD DERIVATIVES WITH 2 DPTR's
ECHO      BAUDRATE IS SELF ADJUSTING
GOTO SERIALOK
:SERIAL12
ECHO      USING SECOND SERIAL INTERFACE OF DALLAS 80C320/520/530 WITH 
ECHO      TIMER 1 FOR GENERATING SERIAL CLOCK
ECHO      BAUDRATE IS SELF ADJUSTING
GOTO SERIALOK
:SERIALOK
IF %2A == A GOTO DEFXDATA
ECHO      XDATA START-ADDRESS: 0%200H  USING 256 BYTE
GOTO XDATASPEC
:DEFXDATA
ECHO      XDATA START-ADDRESS: 0FF00H  USING 256 BYTE (default)
:XDATASPEC
IF %3A == A GOTO DEFCODE
ECHO      CODE  START-ADDRESS: 0%300H  USING 5 KBYTE
GOTO CODESPEC
:DEFCODE
ECHO      CODE  START-ADDRESS: 00000H  USING 5 KBYTE  (default)
:CODESPEC

ECHO .
ECHO IMPORTANT:  CHECK ABOVE PARAMETERS BEFORE MONITOR GENERATION
PAUSE
ECHO TRANSLATE FILE: INSTALL.A51 ...
..\BIN\A51 MON_BANK.A51
IF %5A == A GOTO TWOAPARAM
..\BIN\A51 INSTALL.A51 SET (SERIAL = %1) SET (%4) SET(%5)
GOTO GENLCMD
:TWOAPARAM
IF %4A == A GOTO ONEAPARAM
..\BIN\A51 INSTALL.A51 SET (SERIAL = %1) SET (%4)
GOTO GENLCMD
:ONEAPARAM
..\BIN\A51 INSTALL.A51 SET (SERIAL = %1)
ECHO .

:GENLCMD
ECHO LINKING MONITOR-51 ...

REM Generate Linker Command File
ECHO INSTALL.OBJ, >INSTALL.LNK

IF %4A == BANKA GOTO LINKBANK
IF %4A == bankA GOTO LINKBANK
IF %5A == BANKA GOTO LINKBANK
IF %5A == bankA GOTO LINKBANK
GOTO NOLINKBANK
:LINKBANK
ECHO MON_BANK.OBJ, >> INSTALL.LNK
IF %1 == 4  GOTO BDALLAS1
IF %1 == 5  GOTO BDALLAS1
IF %1 == 11 GOTO BDALLAS1
IF %1 == 12 GOTO BDALLAS1
ECHO MON51B.LIB TO MON51 >> INSTALL.LNK
GOTO GENLCMD2
:BDALLAS1
ECHO MON51BDP.LIB TO MON51 >> INSTALL.LNK
GOTO GENLCMD2
:NOLINKBANK
IF %1 == 4  GOTO BDALLAS2
IF %1 == 5  GOTO BDALLAS2
IF %1 == 11 GOTO BDALLAS2
IF %1 == 12 GOTO BDALLAS2
ECHO MON51.LIB TO MON51 >> INSTALL.LNK
GOTO GENLCMD2
:BDALLAS2
ECHO MON51DP2.LIB TO MON51 >> INSTALL.LNK

:GENLCMD2
IF %2A == A GOTO DEFX
ECHO XDATA(XDATA_AREA(0%200H)) >> INSTALL.LNK
GOTO GENLCMD3
:DEFX
ECHO XDATA(XDATA_AREA(0FF00H)) >> INSTALL.LNK
:GENLCMD3
IF %3A == A GOTO DEFC
ECHO CODE(INITSEG(0%300H) >> INSTALL.LNK
GOTO GENLCMD4
:DEFC
ECHO CODE(INITSEG(00000H) >> INSTALL.LNK
:GENLCMD4
ECHO ,INSTALLCODE,STOPSEG,CODE_AREA,GOCODE_AREA) PRECEDE (STACK (08)) >> INSTALL.LNK

REM Link Monitor
..\BIN\BL51 @INSTALL.LNK

ECHO CONVERTING TO INTEL-HEX-FILE ...
..\BIN\OH51 MON51
ECHO .
ECHO USE FILE MON51.HEX FOR PROM PROGRAMMING
GOTO EXIT

:USAGE
ECHO ERROR *** WRONG INVOCATION, USAGE:
ECHO .
ECHO   INSTALL  serialtype  [xdatastart  [codestart  [PROMCHECK][BANK]]]
ECHO .
ECHO   serialtype := 0  using TIMER 1  9600 bps at 11.059 MHz CPU Clock
ECHO   serialtype := 1  using baudr. gen. 9600 bps at 12.000 MHz (80515/80517)
ECHO   serialtype := 2  using TIMER 2  9600 bps at 12.000 MHz CPU Clock
ECHO   serialtype := 3  using serial interface 1  9600 bps at 12.000 MHz (80517) 
ECHO   serialtype := 4  using T2 9600 bps at 12 MHz for DALLAS 80C320/520/530
ECHO   serialtype := 5  using Ser.Ch.1 9600 bps at 12 MHz (DALLAS 80C320/520/530)
ECHO   serialtype := 6  using external UART 16450/16550
ECHO   serialtype := 7  using TIMER 1 with self adjusting baudrate
ECHO   serialtype := 8  using TIMER 2 with self adjusting baudrate
ECHO   serialtype := 9  using baudr. gen. with self adjusting baudrate
ECHO   serialtype := 10 using serial interface 1 with self adj. bdr. for 80517(A)
ECHO   serialtype := 11 using TIMER 2 with self adj. bdr. for DALLAS 80C320/520/530
ECHO   serialtype := 12 using Ser.Ch.1 with self adj. bdr.for DALLAS 80C320/520/530
ECHO .
ECHO   xdatastart must be a page-no.  between 0 and  0FFH inclusive.
ECHO   codestart  must be a block-no. between 0 and  0ECH inclusive.
ECHO   PROMCHECK  checks whether there is a PROM or RAM at address 0
ECHO              DO NOT USE THIS OPTION WHEN codestart IS 00 !!!
ECHO   BANK       generates Monitor-51 with banking support
ECHO EXAMPLE:  INSTALL 0 7F 80
:EXIT
