dan.lewis
Joined: 21 Feb 2007 Posts: 69 Location: Canada
|
Posted: Tue Apr 17, 2007 5:49 pm Post subject: Boot.asm |
|
|
Hi guys,
In the spirit of tidy, sexy code, I'd like to contribute the following:
Code: |
module BootStrap;
align(4) static struct MultibootHeader {
uint magic = 0x1BAD_B002;
uint flags = 0x0000_0003;
uint checksum = -(magic + flags);
}
void _start() {
version(D_InlineAsm_X86) asm {
naked;
cli; // disable interrupts
mov [$$+0x4000], ESP; // initialize the stack pointer
push EBX; // push multiboot information onto the stack
push EAX; // push the magic value onto the stack
call loadMBI; // load the kernel with the multiboot information
call _stop; // program terminator
}
}
void _stop() {
version(D_InlineAsm_X86) asm {
naked;
hlt; // stop the cpu until an interrupt
call _stop; // do it again
}
}
|
_________________ nop
nop ; problem solved |
|