From 86a7c9a8de1d4fb4709f0f0c5e3f1d6f0be1f941 Mon Sep 17 00:00:00 2001 From: Stefan Zabka Date: Wed, 29 Apr 2020 15:14:21 +0200 Subject: Wrote put() --- 01_exercise/bootloader.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/01_exercise/bootloader.c b/01_exercise/bootloader.c index 0260c82..850250d 100644 --- a/01_exercise/bootloader.c +++ b/01_exercise/bootloader.c @@ -3,21 +3,21 @@ asm(".code16gcc\njmp $0, $main"); /* space for additional code */ -void main(void) -{ - asm( - "mov $0x007, %%ebx;" - "mov $0xE4E, %%eax; int $0x10;" - "mov $0xE69, %%eax; int $0x10;" - "mov $0xE63, %%eax; int $0x10;" - "mov $0xE65, %%eax; int $0x10;" - "mov $0xE20, %%eax; int $0x10;" - "mov $0xE42, %%eax; int $0x10;" - "mov $0xE6F, %%eax; int $0x10;" - "mov $0xE6F, %%eax; int $0x10;" - "mov $0xE74, %%eax; int $0x10;" - "mov $0xE73, %%eax; int $0x10;" - "jmp .;" - ::: "eax", "ebx" +char WRITE_CHARACTER_TTY = 0x0E; +void put(char c) { + short command = WRITE_CHARACTER_TTY << 8 | c; + // volatile because there is no output, so the function might get optimized away + asm volatile("int $0x10;" + :: "a"(command) ); } + + +void main(void) +{ + put('h'); + put('e'); + put('l'); + put('l'); + put('o'); +} -- cgit v1.2.3-54-g00ecf