Kernel and BASIC Updates 2020-04-11

Description of your first forum.
Post Reply
User avatar
Posts: 42
Joined: Wed Apr 24, 2019 12:44 am

Kernel and BASIC Updates 2020-04-11

Post by PJW » Sat Apr 11, 2020 5:51 pm

I've been working on some updates for the FMX kernel and the BASIC implementation. I'm hoping you all will find this an exciting update, as it adds something I think will help you use the system more: file commands in BASIC! I have spent the past couple of weeks adding a fairly limited FAT32 implementation to the kernel and then some simple commands to the BASIC interpreter. Details will be documented on the wiki and the documentation for the interpreter on its Github repository, but I want to give an overview here:

FAT32 Features/Limitations:
  • Supports FAT32 formatted SD cards.
  • Only cards formatted with 512B allocation blocks (i.e. 1 sector per cluster) are supported at this time. Support for multiple cluster sizes is probably on the TODO list.
  • Only the root directory is supported. A hierarchical file system is on the TODO list.
  • Long file names are not supported. Only 8.3 file names are supported. Long file names are NOT on the TODO list unless people really want them.
  • IDE and floppy drives are not currently supported (they're on the TODO list)
  • Only original SD standard cards are supported (not SDHC or SDXC). This is due to the hardware and will not change unless the hardware does.
  • Kernel functions have been added for sector level access to the SD and file level access to the FAT32 file system and directory. Documentation will be added to the wiki soon.
BASIC Commands (cannot be used within a program):
  • LOAD <filename> --- Reads a BASIC program from an ASCII text file on the SD card. Because of future plans for the BASIC interpreter, BASIC files are not going to be tokenized.
  • SAVE <filename> --- Saves a BASIC program to an ASCII file on the SD card. The file must not exist before using this command. When the file is created, the date and time are taken from the FMX's real time clock, so be sure to set it properly using the SETTIME and SETDATE statements before you save a file (see the BASIC816 manual).
BASIC Statements (can be used either interactively or in a program):
  • BLOAD <filename> [, <address>] --- Load a binary file into memory. If an address is provided, the first byte of the file will start at that address. "Executable" file formats do not require a destination address (see below).
  • BSAVE <filename>, <start>, <end> --- Save a block of memory from <start> to <end> (inclusive) to a file on the SD card. The file must not already exist on the SD card.
  • BRUN <filename> --- Load and begin running an executable binary file on the SD card.
  • DIR --- Display a directory listing.
  • DEL <filename> --- Delete a file from the SD card.
  • RENAME <original filename>, <new filename> --- Rename a file on the SD card changing <original filename> to <new filename>.
NOTE: I am drawing a distinction between regular binary files and executable binary files. An executable binary file will contain enough information in the file itself to say where the data should be loaded and how to start the machine code in the file. At the moment, there is a single executable file format supported in the kernel ("PGX"), but the kernel is designed to make it relatively easy to add other loaders to the kernel. The PGX format is laid out like so:
  • Bytes 0--2: the ASCII text "PGX", serving as a signature.
  • Byte 3: the byte 0x01. This is intended as a target version and CPU code. The upper 4 bits are the PGX file format version (0), and the lower 4 bits are the CPU code (1 for 65816).
  • Bytes 4--7: the destination address in little endian format. The first byte of binary data will start loading to this address. It is also the location BRUN will call to start execution. So, however your code is laid out, to use PGX, the first byte of data should be executable.
  • Bytes 8--EOF: The rest of the bytes are the data to load.

A few words of warning. The kernel calls I'm adding should be considered as moving targets. I intend to keep developing this file system code, which means the calls may have to change. Also you may find that they need improvements in some ways. Let me know! Additionally, I know of at least two other efforts to implement FAT support for the FMX. As those projects mature, we may decide it makes more sense to remove the kernel additions I've made and integrate one of those other libraries. Time will tell.

Also... THERE WILL BE BUGS! Expect things to go horribly wrong and back up all your files as you build them! This should be considered bleeding edge. If you run into a problem, please let me know. If possible, I'd prefer you filed an issue in the BASIC816 Github repository (or the Kernel_FMX repository if you're pretty sure it's a kernel issue). But you can let me know through Discord or the forum, if you prefer.

I wanted to get this rolled out to you, even in its current state, to try to help you get more out of your FMXs and the BASIC interpreter. I'm hoping these changes will make the computer more "real" for you all.

  • KERNEL.BIN, the flashable BIN file containing the latest kernel and BASIC
  • BASIC816.PDF, the manual for BASIC816 on the C256 Foenix.
  • PGXFile, a sample project that builds an executable PGX file.
Posts: 4
Joined: Sun Apr 12, 2020 3:35 pm

Re: Kernel and BASIC Updates 2020-04-11

Post by sm3 » Sun Apr 12, 2020 3:38 pm

It looks great! Thanks for all the effort you have been putting into this.
User avatar
Posts: 15
Joined: Thu Dec 17, 2020 12:29 pm

Re: Kernel and BASIC Updates 2020-04-11

Post by cydo » Thu Mar 11, 2021 7:24 am

Thanks for your work, I've added a proposal for a chunked pgx format:
Post Reply