Changes in BASIC52/RD2 v1.4beta4

1. The extensions are has been moved back to 2000h-3FFFh (undone item 5. from the first changelog). This allows to use extensions published on the web for the original BASIC52.
The "extra" part of interpreter code has been moved to the 6000h-7FFFh area.

2. Extensions can now return a value through a new function 43h, compatible to BASIC52 version 1.3 published in Elektor. This is to make the extensions published for this version work.

3. Line editor has been further enhanced (see also item 10. in the first changelog). When a VT100-compatible terminal (e.g. Hyperterminal, Tera Term) is used, the following features can be used:

  • cursor can be moved using left and right arrow
  • it is possible to insert text when cursor is in middle of the edited line
  • pressing ESC twice clears the line (in the same way as Ctrl-D does)
  • backspace and delete (if properly set as different keys) work as usually, i.e. "eat" characters to right/from left.

4. Already entered lines now can be edited. Enter the line number followed immediately by a fullstop (e.g. "30."): the appropriate line will be displayed and can be edited.

5. As a parameter to CALL command now a variable can be used.

6. Ported for P89V51RD2 with all the bells and whistles (in-FLASH editing, simulated EEPROM) - not for public download at the moment, sorry.

The AT89C51RD2/ED2 version is still freely available on this website; but please keep in mind that B52RD2v1.4b4 is reportware - your feedback to [basic at efton dot sk] is expected.

Changes in BASIC52/RD2 v1.4 to BASIC52 v1.1

1. The internal XRAM (1 kB for T89C51RD2 and 1.75kB for AT89C51xD2) is used as working RAM, so there is no need to connect external memories (although possible in the lower 32kB above the XRAM). The internal FLASH from address 8000h on is used as ROM, and no external EPROM can be used for this range.

Note: Compared to the original BASIC52 the minimum limit for RAM was lowered to 768 bytes, so it is possible to use second source RD2-compatible mcu (Philips, SST, Winbond). However, for them there remains only 256 bytes of RAM for user data (BASIC itself uses 512 bytes of RAM) and the extensions using FLASH programming described in the following paragraphs cannot be used.

2. The ROM programming routines were modified for FLASH programming (commands PROG, FPROG and PGM).

The programming uses the IAP method implemented in the bootloader, so it must be present.

The FPROG command has now a different meaning:

  • FPROG n - overwrites program on position n, simultaneously erasing programs on higher positions;
  • FPROG 0 - erases all programs in the FLASH;
  • if no parameter is given for FPROG bez parametra, or the parameter n is higher than the highest position, FPROG behaves the same as PROG with no parameter (i.e. the first available position is programmed).

Now commands FPROG and PROG write the address of last programmed byte after sucessful programming.

Caution: there is no check for reaching the highest address in FLASH, i.e. 0F800h/0FC00h (where the bootloader for AT89C51xD2/T89C51RD2 starts).

Caution: as in the original, programming is only possible if the current program is in RAM.

PROG0 cancels PROG1 - PROG6 (i.e. cancels automatic start of the program on the first position in FLASH).

3. Programs can be edited directly in FLASH.

This enables to write programs longer than the available RAM would permit (without need to use the extended syntax - see paragraph 4).

Only the program at highest position can be edited. Lines can be added not just to the end, but also to the beginning and into the middle of the program, but note that in this case a significant part of FLASH is programmed each time a line is added (although it is not likely that the declared endurance of 10000 write cycles will be exceeded during normal use). The NEW command can be used, too.

An easy way to start a new program is to switch to RAM using RAM, clear it using NEW, program this "empty program" into flash using PROG, and switch to the freshly programmed position n using ROM n. Now you can start entering program lines.

When sendig a program from a file, at each line the interpreter must not ony analyse the line but also program it into the FLASH. A typical write cycle according to the datasheet takes around 10 ms, and typically two pages are programmed per program line, so an adequate "line delay" around 100-300ms has to be set in the terminal program (depending on line length and complexity).

4. The GOSUB (and GOTO, although for it is not very useful) command has now an extended syntax, so one can write

GOSUB xxxx,yy

where xxxx is the line number (as in the conventional syntax) and yy is a position of a program in the ROM (yy=0 means RAM) . It means, that a particular ROM position can contain a library of routines, that can be called from other programs.

Of course, the original syntax GOSUB xxxx is still valid.

5. As the interpreter is now more than 10kB long (compared to the original 8kB) the extensions from addresses 20xxh (including the flags) have been moved to addresses 60xxh. (Back to 2000h-3FFFh in v1.4beta4.)

6. Now, clock above 12MHz can be used and its value can be assigned to the XTAL variable.

7. The 2x (i.e. 6-clock) mode can be switched on by appending letter X to the expression assigned to the XTAL variable.

Examples: XTAL = 18432000X or XTAL= XTALX

8. The internal EEPROM can be accessed by writing/reading to/from variable DBY(n), where n is in the range from 100h to 8FFh.

When accessing addresses 100h to 7FFh, EEPROM at addresses 100h to 7FFh is accessed; when accessing address range 800h to 8FFh; EEPROM in the range of 000h to 0FFh is accessed.

Caution: For proper writing to EEPROM it is necessary to set the actual value of clock to the XTAL variable.

9. Now all I/O ports can be used for reading/writing (except P3.0 and P3.1, being RxD and TxD), as they are no more needed for the external bus. They can be accessed by reading/writing variables PORT0, PORT2 and PORT3 in the same way as it is with PORT1. Lower 2 bits written to PORT3 are ignored.

10. In the line editor (used when editing a program, also when entering for the INPUT command), now both DEL (7Fh) and BS (08h) commands can be used as backspace character (erasing the last typed character). This makes easier to use certain terminal programs.

Caution: For the FLASH programming functions (including the direct editing of programs in FLASH) the bootloader must be present (this is mainly for T89C51RD2, where the bootloader can be erased; in AT89C51xD2 the bootloader cannot be erased) and the IAP programming must be enabled (i.e. no security bit set).