Created
June 18, 2019 13:20
-
-
Save unixzii/e2375421e760360c92615287cb31bb69 to your computer and use it in GitHub Desktop.
A damn simple bootloader that prints "Hello, world!".
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__asm__( | |
".code16gcc\n" | |
"jmpl $0, $main\n" | |
); | |
static const char * const msg = "Hello, world!"; | |
void char_out(const char ch) { | |
__asm__( | |
"mov $0x0e, %%ah\n" | |
"mov %0, %%al\n" | |
"int $0x10\n" | |
: : "r"(ch) : "ax" | |
); | |
} | |
void main() { | |
const char *cur = msg; | |
for (;;) { | |
char ch = *(cur++); | |
if (!ch) break; | |
char_out(ch); | |
} | |
__asm__( | |
"hlt\n" | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ENTRY(main); | |
SECTIONS | |
{ | |
. = 0x7c00; | |
.text : AT(0x7c00) | |
{ | |
*(.text); | |
} | |
.data : | |
{ | |
*(.data); | |
*(.rodata*); | |
} | |
.magic : AT(0x7dfe) | |
{ | |
SHORT(0xaa55); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment