## CHAPTER 3

### Description of EPROM File Commands

One of the unique and powerful features of MCS BASIC-52 is that it has the ability to execute and save programs in an EPROM. MCS BASIC-52 actually generates all of the timing signals needed to program most EPROM devices. Saving programs in EPROMs is a much more attractive and reliable alternative relative to cassette tape, especially in control and/or noisy environments.

The hardware needed to permit MCS BASIC-52 to program an EPROM device is minimal, typically only one NAND gate, three or four transistors, and a few resistors are all that is required. Details of the hardware requirements are in the EPROM programming section of this manual.

MCS BASIC-52 can save more than one program in an EPROM. In fact, it can save as many programs as the size of the EPROM memory permits. The programs are stored sequentially in the EPROM and any program can be retrieved and executed. This sequential storing of programs is referred to as the EPROM file. The following commands permit the user to generate and manipulate the EPROM file.

3.1 DESCRIPTION OF EPROM FILE COMMANDS

COMMANDS: RAM(cr) and ROM [integer] (cr)

ACTION TAKEN:

These two commands tell the MCS BASIC-52 interpreter whether to select the current program (the current program is the one that will be displayed during a LIST command and executed when RUN is typed) out of RAM or EPROM. The RAM address is assumed to be 512 (200H) and the EPROM address begins at 32784 (8010H).

RAM

When RAM(cr) is entered MCS BASIC-52 selects the current program from RAM. This is usually considered the "normal" mode of operation and is the mode that most users interact with the command interpreter.

ROM

When ROM [integer] (cr) is entered MCS BASIC-52 selects the current program out of EPROM memory. If no integer is typed after the ROM command (i.e. ROM (cr)) MCS BASIC-52 defaults to ROM 1. Since the programs are stored sequentially in EPROM the integer following the ROM command selects which program the user wants to run or list. If you attempt to select a program that does not exist (i.e. you type in ROM 8 and only 6 programs are stored in the EPROM) the message ERROR: PROM MODE will be displayed.

MCS BASIC-52 does not transfer the program from EPROM to RAM when the ROM mode is selected. So, you cannot edit a program in the ROM mode. If you attempt to edit a program in the ROM mode, by typing in a line number, the message ERROR: PROM MODE will be displayed. The following command to be described, XFER, permits one to transfer a program from EPROM to RAM for editing purposes.

Since the ROM command does not transfer a program to RAM, it is possible to have different programs in ROM and RAM simultaneously. The user can "flip" back and forth between the two modes at any time. Another added benefit of not transferring a program to RAM is that all of the RAM memory can be used for variable storage if the program is stored in EPROM. The system control values - MTOP and FREE always refer to RAM not EPROM.

VARIATIONS:

None.

3.2 DESCRIPTION OF EPROM FILE COMMANDS

COMMAND: XFER(cr)

ACTION TAKEN:

The XFER (transfer) command transfers the current selected program in EPROM to RAM and then selects the RAM mode. If XFER is typed while MCS BASIC-52 is in the RAM mode, the program stored in RAM is transferred back into RAM and the RAM mode is selected. The net result is that nothing happens except that a few milli-seconds of CPU time is used to do a wasted move. After the XFER command is executed, the user may edit the program in the same manner any RAM program may be edited.

VARIATIONS:

None.

3.3 DESCRIPTION OF EPROM FILE COMMANDS

COMMAND: PROG(cr)
PROG is disabled in version 1.2 and will return an ERROR : PROGRAMMING.

ACTION TAKEN:

The PROG command programs the resident EPROM with the current selected program. The current selected program may reside in either RAM or EPROM. This command assumes that the hardware is configured in the manner described in the EPROM programming section of this manual.

After PROG (cr) is typed, MCS BASIC-52 displays the number in the EPROM file the program will occupy.

EXAMPLE:

    >LIST
    10 FOR I=1 TO 10
    20 PRINT I
    30 NEXT I

    READY
    >PROG
     12

    READY
    >ROM 12

    READY
    >LIST
    10 FOR I=1 TO 10
    20 PRINT I
    30 NEXT I

    READY
    >

In this example, the program just placed in the EPROM is the 12th program stored.

3.4 DESCRIPTION OF EPROM FILE COMMANDS

COMMANDS: PROG1(cr) and PROG2(cr)
PROG1 and PROG2 are disabled in version 1.2 and will return an ERROR : PROGRAMMING.

ACTION TAKEN:

PROG1

Normally, after power is applied to the MCS BASIC-52 device, the user must type a "space" character to initialize the 8052AH's serial port. As a convenience, MCS BASIC-52 contains a PROG1 command. What this command does is program the resident EPROM with the BAUD rate information. So, the next time the MCS BASIC-52 device is "powered up," i.e. reset, the chip will read this information and initialize the serial port with the stored baud rate. The "sign-on" message will be sent to the console immediately after the MCS BASIC-52 device completes its reset sequence. The "space" character no longer needs to be typed. Of course, if the BAUD rate on the console device is changed a new EPROM must be programmed to make MCS BASIC-52 compatible with the new console.

NOTES:
PROG1 programs the EPROM with the BAUD rate information and the MTOP information.
On boot, only the BAUD rate is read from the ROM.
The current program (if any) is not programmed into the EPROM.
The 'sign-on' message is not displayed.

PROG2

The PROG2 command does everything the PROG1 command does, but instead of "signing-on" and entering the command mode, the MCS BASIC-52 device immediately begins executing the first program stored in the resident EPROM.

By using the PROG2 command it is possible to RUN a program from a reset condition and never connect the MCS BASIC-52 chip to a console. In essence, saving PROG2 information is equivalent to typing a ROM 1, RUN command sequence. This is ideal for control applications, where it is not always possible to have a terminal present. In addition. this feature permits the user to write a special initialization sequence in BASIC or assembly language and generate a custom "sign-on" message for specific applications.

NOTES:
PROG2 programs the EPROM with the BAUD rate information and the MTOP information.
On boot, only the BAUD rate is read from the ROM.
The current program (if any) is not programmed into the EPROM.
The 'sign-on' message is not displayed.

3.5 DESCRIPTION OF EPROM FILE COMMANDS

COMMANDS: FPROG(cr), FPROG1(cr), and FPROG2(cr)
FPROG, FPROG1, and FPROG2 are disabled in version 1.2 and will return an ERROR : PROGRAMMING.

ACTION TAKEN:

FPROG(cr), FPROG1(cr), and FPROG2(cr) do exactly the same thing as PROG(cr), PROG1(cr), and PROG2(cr) respectively, except that the algorithm used to perform the programming function is the INTEL "intelligent" fast programming algorithm. The user must provide a way to increase Vcc to the EPROM to 6 volts.

COMMANDS: PROG3(cr), PROG4(cr), FPROG3(cr), FPROG4(cr) (VERSION 1.1 ONLY)
PROG3, PROG4, FPROG3 and FPROG4 are disabled in version 1.2 and will return an ERROR : PROGRAMMING.

ACTION TAKEN:

PROG3

The PROG3 command functions the same way as the PROG1 command previously described, except that PROG3 also saves the system control value, MTOP, when it is evoked. During a reset or power- up sequence MCS BASIC-52 will only clear the external data memory up to the MTOP value that was saved when the PROG3 command was evoked. This permits the user to "protect" regions of memory from being cleared during a reset or power-up condition. In typical use, the PROG3 command assumes that the user is saving some critical information in some type of battery-backed-up or non-volatile memory and does not want this information to be destroyed during a reset or power-up sequence.

NOTES:
PROG3 programs the EPROM with the BAUD rate information and the MTOP information.
On boot both the BAUD rate and the MTOP value are read from the ROM.
The current program (if any) is not programmed into the EPROM.
The 'sign-on' message is not displayed.

PROG4

The PROG4 command is a combination of the PROG2 and PROG3 commands. PROG4 saves the same information as PROG3, but also executes the first program stored in the EPROM after a reset or power-up condition.

NOTES:
PROG3 programs the EPROM with the BAUD rate information and the MTOP information.
On boot both the BAUD rate and the MTOP value are read from the ROM.
The current program (if any) is not programmed into the EPROM.
The 'sign-on' message is not displayed.

FPROG3 and FPROG4

The FPROG3 and FPROG4 commands save the same information as the PROG3 and PROG4 commands respectively, except that the INTELIigent(tm) algorithm is used to program the EPROM.

COMMANDS: PROG5(cr), PROG6(cr), FPROG5(cr), FPROG6(cr) (VERSION 1.1 ONLY)
PROG5, PROG6, FPROG5 and FPROG6 are disabled in version 1.2 and will return an ERROR : PROGRAMMING.

ACTlON TAKEN:

PROG5 & FPROG5

The PROG5 command saves both the baud rate information and the MTOP information, just like the PROG3 command previously described. However, during a reset or power-up condition the MCS BASIC-52 device examines external data memory location 5FH (95 decimal). If the user has placed the value 0A5H (165 decimal) in this location, the MCS BASIC-52 device will not clear the external memory during a RESET or power-up condition. This permits the user to "save" programs in external memory, providing some type of battery back-up scheme has been employed.

Normally, when using the PROG5 command to establish the reset or power-up condition, the MCS BASIC-52 device will enter the command mode after reset or power-up. However, if the user wishes to execute the program stored in external memory, the character 34H (52 decimal) needs to be placed in external memory location 5EH (94 decimal). Placing a 34H in location 5EH causes MCS BASIC-52 to enter the "run trap mode".

NOTES:
PROG5 programs the EPROM with the BAUD rate information and the MTOP information.
On boot only the BAUD rate is read from the ROM. If the external RAM was preserved, the MTOP value is as it was.
The current program (if any) is not programmed into the EPROM.
The 'sign-on' message is displayed, and if the run-trap mode is active, the first program in RAM is RUN. Note that RUN causes all the BASIC variables to be cleared.

PROG6 & FPROG6

Does the same thing as PROG5, but calls external program memory location 4039H during a reset or power-up sequence. This option also requires the user to put the character 0A5H in external memory location 5FH to insure that external RAM will not be cleared during reset or power-up. The user must put an assembly language initialization routine in external code memory location 4039H or else this reset mode will crash. When the user returns from the customized assembly language reset routine, three options exist:

OPTION 1 FOR PROG6

If the carry bit is cleared (c = 0) upon return from the user reset routine MCS BASIC-52 will enter the auto-baud rate determining routine. The user must then type a space character (20H) on the terminal to complete the reset routine and produce a reset message on the terminal.

OPTION 2 FOR PROG6

If the carry bit is set (c = 1) and bit 0 of the accumulator is cleared (ACC.0 = 0) MCS BASIC-52 will produce the standard sign-on message upon return from the user supplied reset routine. The BAUD rate will be the one that was saved when the PROG6 option was used.

OPTION 3 FOR PROG6

If the carry bit is set (c = 1) and bit 0 of the accumulator is set (ACC. 0 = 1), MCS BASIC-52 will execute the first program stored by the user in EPROM (starting address of the program is 8010H) upon return from the user supplied reset routine.

NOTES:
PROG6 with option 3 programs the EPROM with the BAUD rate information and the MTOP information.
On boot only the BAUD rate is read from the ROM If the external RAM was preserved, the MTOP value is as it was.
The current program (if any) is not programmed into the EPROM.
The 'sign-on' message is not displayed and the first program in ROM is RUN. Note that RUN causes all the BASIC variables to be cleared.