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 a virtual "EPROM".  While the DS-5000 actually generates all of the timing signals needed to program most EPROM devices, we use a porti on of the 32K "topside" memory to save these programs.  Access is primitive: serially by number, but it is quite reliable and can allow the automatic execution of a variety of BASIC-5000 programs upon power-up.  You can allow lock-out user modif ication of the executing program (control-C) with a subset of these commands.

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 (2000H) or 8192 bytes in decimal.  The programs are stored sequentially in the EPROM and any program can be r etrieved 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.

NOTE: If available, program saving and loading is more efficiently done on the development workstation.  To download a program, the workstation "types in" the program.  The loader must wait for the BASIC-5000 prompt ">".  The li ne-at-a-time text-transfer mode setting in the Windows terminal accessory works fine with ">" set as the prompt.


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 t o be (3300H) and the EPROM address begins at (6010H).  In the DS-5000, this is implemented by partitioning the 32K RAM as ROM between 0 and 2FFFH and RAM from 3000H to 7FFFH.  The size of memory is determined and cleared during initialization (a nd NEW) but the operation is limited to the current value of MTOP.  The default value of MTOP is 5FFFH resulting in 6000 to 7FFFH being available for "EPROM" in the sense that it will not be cleared by the initialization procedure.  MTOP can be changed and this changed value will then be used during initialization.

RAM

When RAM(cr) is entered MCS BASIC-52 selects the current program from RAM MEMORY.  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 t he 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 b e 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 MO DE 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.


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 sele cted.  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.


COMMAND: ERASE(cr)

ACTION TAKEN:

ERASE erases everything stored above the current value of the special control variable, MTOP.  It erases all programs, not simply the currently selected program.  It does not erase a current program in RAM.


COMMAND: PROG(cr)

ACTION TAKEN:

The PROG COMMAND programs the allocated portion of the DS5000 32K memory (that above MTOP) with the current selected program.  The current selected program may reside in either RAM or EPROM.  

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.


COMMAND: RROMn

ACTION TAKEN:

RROMn runs program n.  It does nothing if program n doesn't exist.  RROM without an argument runs the first program stored.  It is the same as RROM1.


COMMANDS: PROG2(cr)

ACTION TAKEN:

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 PROG2 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.  Then, instead of "signing-on" and enter ing the COMMAND MODE, the MCS BASIC-52 device immediately begins executing the first program stored in the resident EPROM.  It is rather like AUTOEXEC.BAT on IBM-compatible DOS machines.  THIS IS AN IMPORTANT FEATURE!! By using the PROG2 comman d 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.   The DS-5000 communicates at 9600 baud.  TIMER1 provides serial communications and can be examined or modified.  For 9600 BAUD, TIMER1=0FAFBH.


3.2 FORMAT OF AN BASIC-5000 PROGRAM

Each line of BASIC-5000 text consists of tokens and ASCII characters, plus 4 bytes of overhead.  Three of these four bytes are stored at the beginning of every line.  The first byte contains the length of a line in binary and the second two byte s are the line number in binary.  The fourth byte is stored at the end of the line.  This byte is always a 0DH or a carriage return in ASCII.  An example of a typical line is shown below.  Assuming that this is the first line of a prog ram in RAM, BASIC-5000 starts program storage at location 3300H.

10 FOR I = 1 TO 10: PRINT I: NEXT I

LOCATION BYTE DESCRIPTION
3300H 11H THE LENGTH 0F THE LINE IN BINARY (17 Decimal BYTES)
3301H 00H HIGH BYTE OF THE LINE NUMBER
3302H 0AH LOW BYTE OF THE LINE NUMBER
3303H 0A0H THE TOKEN FOR "FOR"
3304H 49H THE ASCII CHARACTER "I"
3305H 0EAH THE TOKEN FOR " - "
3306H 31H THE ASCII FOR "1"
3307H 0A6H THE TOKEN FOR "TO"
3308H 31H THE ASCII FOR "1"
3309H 30H THE ASCII FOR "0"
330AH 3AH THE ASCII FOR ":"
330BH 89H THE TOKEN FOR "PRINT"
330CH 49H THE ASCII FOR "I"
330DH 3AH THE ASCII FOR ":"
330EH 97H THE TOKEN FOR "NEXT"
330FH 49H THE ASCII FOR "I"
3310H 0DH END OF LINE (CARRIAGE RETURN)

To find the location of the next line, the length of the line is added to the location where the length of the line is stored.  In this example. 3300H + 11H = 3311H, which is where the next line is stored.

The END of a program is designated by the value 0IH.  So, in the previous example if line 10 was the only line in the program, location 3311H would contain the value 01H.  A program simply consists of a number of lines packed together in one con tinuous block with the last line ending in a 0DH, 01H sequence.

The EPROM FILE format consists of the same line and program format, previously described except that each program in the EPROM file begins with the value 55H.  The value 55H is only used by MCS BASIC52 to determine if a valid program is present. &nbs p;For example, If the user types ROM 6, BASIC-5000 actually goes through the first program stored in EPROM line by line until the END of PROGRAM (01H) is found, then it examines the next location to see if a 55H is stored in that location.  It then g oes through that program line by line.  This process is repeated 6 times.  If the character 55H is not found after the end of a program, BASIC-5000 will return with the PROM MODE error message.  This would mean that less than six programs w ere stored in that EPROM.  The first program stored in EPROM (ROM 1) always begins at location 6010H and this location will always contain a 55H.  The actual user program will begin at location 601IH.

EPROM locations 6000H through 600FH are reserved by BASIC-5000.  These locations contain initialization information when the PROGX options are used.  If location 6000H contains 32H, then the first BASIC program, ROM1, starting at location 6010H, will be immediately executed.  This can be realized with the command line: XBY(6000H)=32H.