BASIC - 52 VOCABULARY


Here is a BRIEF list of the commands in the BASIC - 52 vocabulary. If you know BASIC, you will probably recognize most of them.

There are actually many more, ( over 100, total ) but most of the ones not shown here are mostly machine "utilities", oriented towards direct control and use of the internal features of the 8052 chip. This includes the internal timer, individual I/O pins, interrupt pins, and various control registers for the CPU.

The BASIC - 52 manual from Systronix has a VERY detailed and complete description of the interpeter, data storage at the byte level, and methods for calling and using assembly routines... it even shows how assembly routines can directly call and use many of the BASIC - 52 instructions... you don’t find programming books like this anymore...

Control commands :

RUN     CTRL_C    CTRL_S     CTRL_Q     CTRL_D
PROM    RAM       XFER       CONT       CLEAR
NEW     RROM      LIST       MTOP       END
FREE    XTAL      STOP

EPROM programmer commands :

PROG    PROG1     PROG2      PROG3      PROG4     PROG5      PROG6
FPROG   FPROG1    FPROG2     FPROG3     FPROG4    FPROG5     FPROG6
PGM

Math commands : ( in addition to all the usual arithmetic functions  )

ABS     INT       RND        SGN        SQR       SIN
ATN     EXP       X^Y        LOG        COS       TAN

Logical commands :

AND     OR        NOT        XOR

Flow control :

GOTO    FOR-NEXT-STEP     DO-WHILE      DO-UNTIL     GOSUB-RETURN
        IF-THEN-ELSE      ON-GOSUB      ON-GOTO

Input / output and string functions :

INPUT     PRINT     PRINT-USING     ASC      CHR     SPC     TAB
STRING    DATA      DIM             CHR      CR      READ    RESTORE


A DOWNLOAD PROGRAM


Here is a ( free ) MsDos "download" program for the 8052 SBC, which will allow you to download programs ( saved as NotePad files ) directly to the BASIC-52 SBC, from an IBM.

IBM / BASIC-52 DOWNLOAD PROGRAM

It is written in QuickBasic 4.0, and ( when invoked ) will ask for the the complete filename, ( with MsDos pathname and file extension ) the baud rate, the RS232 COM port for the download ( either 1 or 2 ) and the download "speed", expressed as a number ranging from 0.001 to 1000... ( explanation later, in DOWNLOAD CAVEATS )

After that, it will open the file and automatically download it to the BASIC - 52 interpeter, one line at a time, until it reaches the end-of-file.

If you simply hit the return key when this program asks for a filename, the program will expect to find the information stored in a small text file called "BAS52.ini", which MUST be located directly/exactly in the C:\ directory. ( EXAMPLE : c:\BAS52.ini )

The ".ini" file must contain 4 lines...

                    filename ( with path and extension)
                    baud rate
                    COM port
                    Download speed

For example, the contents of "C:\BAS52.ini" might be :

                    C:\BAS52\TRIGTAB.txt
                    1200
                    2
                    1.5

The filename must not exceed 8 characters. The baud rate must be a standard value, ( 600, 1200, 2400, 4800 or 9600 ) and the COM port must be 1 or 2. The download speed is a positive number ranging from 10000 to 0.0001, which will have different values for different computers. ( different CPU speeds ) The correct value for this number can be determined experimentally.... for my computer, ( 130 MHz Pentium ) the correct value is 1.0.

Don't forget to terminate the last line with a carriage return, because the download program expects it.

A download program is a very useful utility because HyperTerminal is not ( really ) suitable for this purpose... the BASIC - 52 interpeter takes a few dozen milliseconds after each line is sent, to scan for syntax errors, "tokenize" the code, and store it in RAM... Following this, it indicates that it is ready for the next line by printing a "prompt" character. ( ">" ) If a new line is sent ( or partially sent ) by the host computer before the interpeter is ready to recieve it, syntax errors will result. This will happen with HyperTerminal if it is merely instructed to send a complete text file to the BASIC-52 SBC.... it won't wait for the BASIC-52 "prompt" character, after each line is sent.

BASIC - 52 is impressive, but it has no “line edit” features... changing a line of code requires that the entire line be re-entered from the beginning. HyperTerminal or a “dumb terminal” can be used to ( manually ) write and edit programs in this manner, but it is a pain... A download program allows the user to create, edit, save and download BASIC - 52 programs in a Windows NotePad file, and employ the ( modest, but superior ) editing features of NotePad.

If you want to UPLOAD a file that was created ( with HyperTerminal ) in the BASIC - 52 computer, ( and save it on your IBM ) you can easily do this with HyperTerminal... just execute a LIST command, and "capture" the HyperTerminal text into a NotePad file. ( Don't forget to remove all the "non - program" keystrokes and interpeter replies )


CAVEATS OF THE DOWNLOAD PROGRAM


There are a few things worth knowing about the download program... The BASIC-52 interpeter will not "erase" any old lines whenever a new program is downloaded, unless it first executes a NEW instruction. If the ( download ) source file contains a line which has the same line number as a pre-existing line, it will overwrite the old line, and there is no problem. However, if the old program contains a line of code which has a unique line number ( one which is NOT overwritten by a line in the new program ) it will REMAIN in the BASIC-52 memory, and it will be "merged into" the downloaded program.

To make sure that this does not ( accidentally ) happen, the first line of each download file should contain a single word, ( "NEW" ) which will be interpeted as an "immediate execute" keyboard command to erase all the old lines of code.

Conversely, this "problem" can be a "virtue", if it is used wisely... It allows the user to create "modules" of code, with certain "blocks" of line numbers reserved for each module... Multiple source files can then be downloaded and "merged together" into a single program.

The download program uses a software timing loop to generate a time delay after sending each character. This gives the UART time to finish transmission before the program sends the next character. This is a pretty "cheezy" way to do it, and it makes the program sensitive to the CPU speed of the computer that runs it... The last parameter in the ".ini" file provides a means to adjust this speed for individual computers. The program is designed so that a value of 1.0 works fine on my computer, but your computer might require larger ( or smaller ) values. If the downloaded text is examined with HyperTerminal and found to be "garbled", the number must be increased. If the download runs much too slow, the number can be reduced.

Different baud rates should not alter the value of this number, ( once it is discovered by experiment ) because the baud rate is "factored out" by the download program.... changing to a slower baud rate will automatically adjust the delay time, using this number.

The COM port must be "free" when the download begins, so make sure to disconnect the HyperTerminal program from the COM port before using the download program. It is not necessary to close HyperTerminal, just "hang up" until the download is completed. Similarly, you must ( manually ) close the window for the download program, ( when the download is completed ) or else the COM port will not be "liberated" for HyperTerminal to use.

The download program is very rudimentary, and does not check for any error messages from the BASIC-52 interpeter, in case there is a download problem. If the download program does not recieve a BASIC-52 "prompt" character within 2 seconds after completion of each line, it will beep and proceed to the next line. It will also beep ( once ) when the download is completed, but this is normal.


[HOME PAGE][NEXT PAGE]