Anonymous user
D Bare Bones: Difference between revisions
Jump to navigation
Jump to search
update D code to use volatileStore and update commands to assume a non-i386 compilation environment
[unchecked revision] | [unchecked revision] |
No edit summary |
(update D code to use volatileStore and update commands to assume a non-i386 compilation environment) |
||
Line 90:
<source lang="d">
module kernel.main;
import core.bitop; // will be core.volatile in later gdc
extern(C) void main(uint magic, uint addr) {
int xpos = 0;
const uint COLUMNS = 80; //Screensize
const uint LINES = 25;
ubyte* vidmem = cast(ubyte*)0xFFFF_8000_000B_8000; //Video memory address
for (int i = 0; i < COLUMNS * LINES * 2; i++) { //Loops through the screen and clears it
}
for (;;) { //Loop forever. You can add your kernel logic here
}
Line 113 ⟶ 114:
You then compile that with:
<source lang="bash">gdc -fno-druntime -m32 -c kernel.main.d -o kernel.main.o -g</source>
==linker.ld==
Line 153 ⟶ 154:
Now finally you can link all of that with:
<source lang="bash">ld -melf_i386 -T linker.ld -o kernel.bin start.o kernel.main.o</source>
<source lang="bash">qemu-system-i386 -kernel kernel.bin</source>
▲Your kernel is now kernel.bin, and can now be booted by grub.
Note the "-fno-druntime" argument above. This is how gdc spells the -betterC flag from other D compilers, and the "Better C" page of the D language reference explains how this limits the language. If you want to drop that you'll have to add the D runtime to your kernel.
Hopefully this has gotten you started on writing your operating system in the D programming language.
|