972
edits
[unchecked revision] | [unchecked revision] |
(Created page with "{{TutorialExplain}} {{BeginnersWarning}} {{Rating|1}}{{Template:Kernel designs}} In this Tutorial, we will continue to write the kernel in D, making a basic output to the cons...") |
m (Bot: Replace deprecated source tag with syntaxhighlight) |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 13:
==start.asm==
<
global start
extern
extern start_ctors, end_ctors, start_dtors, end_dtors
Line 74:
resb STACKSIZE
</syntaxhighlight>
Assemble that with:
<
==kernel.main.d==
<
module kernel.main;
import core.
extern(C): // We denote that all functions in our file will have the extern(C) flag
Line 91:
// Creating variables to indicate the cursor position.
// All global dynamic variables need to be marked with the shared flag, because there is no TLS in our kernel
shared int xpos = 0;
shared int ypos = 0;
Line 129 ⟶ 130:
}
void
puts("Hello, world".ptr); // Output "Hello, world!" to the console
Line 137 ⟶ 138:
}
}
</syntaxhighlight>
You then compile that with:
<
==linker.ld==
<
OUTPUT_FORMAT(elf32-i386)
ENTRY (start)
Line 176 ⟶ 177:
end = .; _end = .; __end = .;
}
</syntaxhighlight>
Now finally you can link all of that with:
<
Your kernel is now kernel.bin, and can now be booted by grub, or run in qemu:
<
[[Category:Bare bones tutorials|D bare bones]]
|