Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * https://stackoverflow.com/questions/32931063/write-a-simple-bootloader-helloworld-error-function-print-string
- */
- asm(".code16gcc");
- asm("jmpl $0x0000, $main\n");
- void getch();
- void cout(const char* str);
- void main()
- {
- asm volatile("xor %ax, %ax\n");
- asm volatile("mov %ax, %ds\n");
- cout("BootLoader\n\r");
- cout("Hello World\n\n\r");
- cout("Press any keys to continue");
- getch();
- cout("\n\n\rDone\n\r");
- cout("You can now shutdown the computer");
- asm volatile("cli\n");
- asm volatile("hlt\n");
- }
- void getch()
- {
- asm volatile("xorw %ax, %ax\n" "int $0x16\n");
- }
- void cout(const char* str)
- {
- while(*str)
- {
- asm volatile("int $0x10" : : "a"(0x0e00 | *str), "b"(0x0007));
- ++str;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement