FreeBASIC

From OSDev Wiki

Jump to: navigation, search

Contents

Overview

FreeBASIC is a modern basic compiler with lots of features useful for OS Development. Apart from being mostly QuickBasic compatible, it offers the following useful features:

  • Unsigned data types
  • Inline assembly
  • Pointers
  • Callbacks
  • A mostly platform-independent runtime is included

The major downside is that most of the BASIC-specific instructions require the runtime which can not be easily used in an freestanding environment. The consequence is that typical BASIC constructs can not be used, which is a likely point of confusion for new programmers.

Usage

FreeBASIC has a command line syntax similar to that of GCC:

fbc -c -o kernel.o kernel.bas

to link the output:

ld -T script.ld -o kernel.bin kernel.o

Runtime Library

In an freestanding environment, the runtime is unavailable. Programmers should take care not to use any of the following:

  • Strings
  • Dynamic arrays (only local, fixed-size arrays are allowed)
  • Globals of any kind. All information must be passed in arguments.
  • All non-primitive built-in functions, i.e. anything more complex than + - * / and the logic operators.
  • IO functions, including port outs and ins, peek and poke.

you'll need to provide a runtime init to allow the use of globals, you'll need a malloc() to get strings and arrays working (the rest of the dependencies are cross-platform ctype+stdlib functions and don't pose much of a problem).

See Also

External Links

Personal tools