ECHO OFF
ECHO .
ECHO INSTALL PROCEDURE FOR MONITOR-51  V2.0
ECHO COPYRIGHT KEIL ELEKTRONIK GmbH 1988-1996
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
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 (only valid for 8052)
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 2 FOR GENERATING SERIAL CLOCK
ECHO      ONLY FOR DALLAS 80C320/520/530
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 12.000 MHz
GOTO SERIALOK
:SERIAL7
ECHO      USING EXTERNAL SERIAL INTERFACE 82510 (e.g. DECT Board)
ECHO      BAUDRATE: 9600 bps
: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 TRANSLATE FILE: INSTALL.A51 ...
A51 MON_BANK.A51
IF %5A == A GOTO TWOAPARAM
A51 INSTALL.A51 SET (SERIAL = %1) SET (%4) SET(%5)
GOTO GENLCMD
:TWOAPARAM
IF %4A == A GOTO ONEAPARAM
A51 INSTALL.A51 SET (SERIAL = %1) SET (%4)
GOTO GENLCMD
:ONEAPARAM
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 ECHO MON_BANK.OBJ, >> INSTALL.LNK
IF %4A == bankA ECHO MON_BANK.OBJ, >> INSTALL.LNK
IF %5A == BANKA ECHO MON_BANK.OBJ, >> INSTALL.LNK
IF %5A == bankA ECHO MON_BANK.OBJ, >> INSTALL.LNK

IF %1 == 4 GOTO DALLAS
IF %1 == 5 GOTO DALLAS
IF %1 == 7 GOTO ECO
ECHO MON51.LIB TO MON51 >> INSTALL.LNK
GOTO GENLCMD2
:DALLAS
ECHO MON51DP2.LIB TO MON51 >> INSTALL.LNK
:ECO
ECHO MON51ECO.LIB TO MON51 >> INSTALL.LNK
GOTO GENLCMD2
: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
L51 @INSTALL.LNK

ECHO CONVERTING TO INTEL-HEX-FILE ...
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 external serial interface 80510 with ECO/DECT board
ECHO .
ECHO   xdatastart must be a page-no.  between 0 and  0FFH inclusive.
ECHO .
ECHO   codestart  must be a block-no. between 0 and  0ECH inclusive.
ECHO .
ECHO   PROMCHECK  checks whether there is a PROM or RAM at address 0
ECHO              DO NOT USE THIS OPTION WHEN codestart IS 00 !!!
ECHO .
ECHO   BANK       generates Monitor-51 with banking support
ECHO .
ECHO EXAMPLE:   INSTALL 0 7F 80
:EXIT
