Skip to content
tt1542 edited this page Jun 20, 2026 · 4 revisions

Welcome to the BASCOMP BASIC Compiler wiki!

What's this about?

The BASCOMP compiler has been designed and written in early 2026, supported by experienced programmers and an AI. It is a retro computing tool designed to create COM executable files for DOS-compatible systems like FreeDOS. It is written in BASIC itself and designed to be self-compileable. Thus, the compiler itself has to fit within the 65.280 bytes provided for in the .COM model.

The compiler code follows the established principle of spaghetti code. And its spaghettiness has been optimized for size - so don't expect it to be very readable.

Getting started

In order for BASCOMP to work, you are recommended to extract all its files into one single directory. There is no management of working paths built into the compiler at the moment. Update: BASCOMP 2.2 now does support calling BASCOMP from other directories, e.g. by using the PATH variable!

At the very least, the following files need to be present:

  • BASCOMP.COM - the very compiler you will be using
  • HEADER.ASM - header file for the assembly output of BASCOMP
  • RUNTIME.ASM - assembly runtime file. Sections of this will be added to your assembly output file as needed

For recompiling the compiler you will also need:

  • ASMPACK.COM - reduces the code generated by about 30 percent through cleverly optimizing the output of BASCOMP (recommended for all other use cases as well!)
  • TIMEIT.COM - measuring how long it takes to generate your code. Okay, you don't REALLY need this but it is included in the BUILD and BN batch files (see below).

In case you would like to run this on an 8086/8088 machine you should also use:

  • BASM.COM - a special assembler that only knows about statements generated by BASCOMP and generates x86-compatible machine code.

For your convenience, you can also use the following batch files:

  • BUILD.BAT - this will call BASCOMP, ASMPACK and BASM and take care that you will get COM files directly out of your BAS programms. Use it like this: "build program" without extension.
  • BN.BAT - (build native version) this is the script for the compiler recompiling itself. You won't probably need this, but if you like, play around with it.

REALLY getting started

You can try something like this:

10 PRINT "Hello, world!"
20 END

You might then save this in the same folder as BASCOMP, using the name of HW.BAS, for example, and then type:

C:\BASCOMP\> bascomp hw

BASCOMP will then generate HW.ASM. This is NASM compatible source code. In order to generate an executable, either type

C:\BASCOMP\> basm hw

in order to use the BASM special assembler supplied by BASCOMP itself. Or you can use NASM, provided that it is properly installed and can be found using your PATH or otherwise:

C:\BASCOMP\> nasm -o hw.com hw.asm

Having fun

BASCOMP has been built to support a certain spectrum of types of code. So, the following programs all will be valid.

Using QBasic/QuickBASIC compatible mode (will be detected automatically):

PRINT "Hello, world!"
END

Using shorthand codes for PRINT(?) and END(.):

?"Hello, world!"
.

And of course statements can be packed into one line:

?"Hello, world!":.

Since END is an optional statement, you can also use this:

?"Hello, world!"

Feel free to further try out the obfuscated code capabilities of BASCOMP... ;-)

Using the BASCOMP tool chain

Your polite developer recommends always using

C:\BASCOMP\> build progname

so that the different BASCOMP tools will be called in order. In detail, this will involve:

  • BASCOMP generating an ASM file (like PROGNAME.ASM)
  • ASMPACK packing this very file into an optimized version (like PROGNAME.AS2)
  • BASM taking the optimized file and generating a COM file (like PROGNAME.COM)

Recompiling the compiler

The compiler can be recompiled using

C:\BASCOMP\> bn

and you just need to keep one thing in mind: The resulting binary needs to be smaller than 65.281 bytes, or the COM file will not run.

Supported functions and statements

See the page Supported functions and statements