D Bare Bones II: Difference between revisions

m
Bot: Replace deprecated source tag with syntaxhighlight
[unchecked revision][unchecked revision]
(Fix D Bare bones: now you should import core.volatile module for volatile)
m (Bot: Replace deprecated source tag with syntaxhighlight)
 
(One intermediate revision by the same user not shown)
Line 13:
==start.asm==
 
<sourcesyntaxhighlight lang="asm">
 
global start
Line 74:
resb STACKSIZE
 
</syntaxhighlight>
</source>
 
Assemble that with:
 
<sourcesyntaxhighlight lang="bash">nasm -f elf -o start.o start.asm</sourcesyntaxhighlight>
 
==kernel.main.d==
<sourcesyntaxhighlight lang="d">
module kernel.main;
import core.volatile;
Line 138:
}
}
</syntaxhighlight>
</source>
 
You then compile that with:
 
<sourcesyntaxhighlight lang="bash">gdc -fno-druntime -m32 -c kernel.main.d -o kernel.main.o -g</sourcesyntaxhighlight>
==linker.ld==
<sourcesyntaxhighlight lang="c">
OUTPUT_FORMAT(elf32-i386)
ENTRY (start)
Line 177:
end = .; _end = .; __end = .;
}
</syntaxhighlight>
</source>
 
Now finally you can link all of that with:
 
<sourcesyntaxhighlight lang="bash">ld -melf_i386 -T linker.ld -o kernel.bin start.o kernel.main.o</sourcesyntaxhighlight>
Your kernel is now kernel.bin, and can now be booted by grub, or run in qemu:
 
<sourcesyntaxhighlight lang="bash">qemu-system-i386 -kernel kernel.bin</sourcesyntaxhighlight>
 
[[Category:Bare bones tutorials|D bare bones]]