FreeBasic Bare Bones: Difference between revisions

Jump to navigation Jump to search
finalized tutorial
[unchecked revision][unchecked revision]
(finalized tutorial)
Line 1:
While the forum has several flamewars about BASIC, it is a turing-complete language. FreeBasic adds functionality that makes it suitable for OS development. This tutorial provides a working kernel in Basic, together with the pitfalls associated with it.
{{In Progress}}
 
== About FreeBasic and the Runtime ==
Line 8:
When you get messages about undefined symbols starting with fb_, it means you are using parts of the Runtime.
 
To compensate, FreeBasic provides pointers that can be used to perform functionality the runtime would provide. Inline assembly can be used as well.
 
== Pointers for Beginners ==
Pointers can be difficult to understand. Many modern languages do not work with pointers, while if you know a language like C, C++ or Assembly, you will probably know what they do. Since you will need to use them, a quick introduction in how they work in FreeBasic.
 
The computer uses a set of registers, and memory. Memory is divided into bytes, each byte has its own location number. Big numbers, strings, types and arrays use up multiple bytes. These bytes are stored next to each other. A Long will hold 4 bytes, and will for example occupy locations 239394, 239395, 239396 and 239397. In the computer, these location numbers are called addresses (like the address when sending letters)
Line 194:
<pre>fbc -c -o kernel.o kernel.bas
i586-elf-ld -T link.ld -o kernel.bin kernel.o</pre>
 
<tt>kernel.bin</tt> can then be loaded by [[GRUB]]
 
== Getting the Runtime to work ==
Line 201 ⟶ 203:
Some functions compile cleanly with minimal effort. When you compile the CType, String and Stdlib (excluding malloc, calloc, and free) parts of the runtime can be compiled on top of those.
Before you can use the string and array instructions, you will need to have [[Memory Management|memory management]] implemented. That will allow you to compile malloc, calloc, free from the C library, after which the string and some of the array functions can be compiled. (Newlib can be [[porting Newlib|compiled completely]] when it has memory management functionality)
 
[[Category:Bare bones tutorials]]
1,490

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu