Skip to content

Instantly share code, notes, and snippets.

@ghaiklor
Last active April 20, 2019 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ghaiklor/f976d731c50db2f39d263f3e65756500 to your computer and use it in GitHub Desktop.
Save ghaiklor/f976d731c50db2f39d263f3e65756500 to your computer and use it in GitHub Desktop.
Print alphabet without libc
extern void loader_main() {
for (int i = 0; i < 26; i++) {
char c = 0x41 + i;
asm(
"mov %0, %%al;"
"mov $0x0E, %%ah;"
"int $0x10;"
:
: "r" (c)
);
}
}
@JL2210
Copy link

JL2210 commented Apr 20, 2019

Here's a way to do Hello, World! in BIOS (please update your blog, too):

void loader_main(void) {
        char string[] = "Hello, World!\r\n";
        int length = sizeof[string];
	for (int i = 0; i < length; i++) {
		asm(
			"mov %0, %%al;"
			"mov $0x0E, %%ah;"
			"int $0x10;"
			:
			: "r" (string[i])
		);
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment