FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Boot.asm

 
Post new topic   Reply to topic     Forum Index -> Titan
View previous topic :: View next topic  
Author Message
dan.lewis



Joined: 21 Feb 2007
Posts: 69
Location: Canada

PostPosted: Tue Apr 17, 2007 5:49 pm    Post subject: Boot.asm Reply with quote

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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Titan All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group