From bc48fa46034d4bf2adcdfc94ee64b385b0e4a494 Mon Sep 17 00:00:00 2001 From: Stefan Zabka Date: Wed, 29 Apr 2020 16:29:00 +0200 Subject: Wrote print() --- 01_exercise/bootloader.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/01_exercise/bootloader.c b/01_exercise/bootloader.c index 850250d..fe2d829 100644 --- a/01_exercise/bootloader.c +++ b/01_exercise/bootloader.c @@ -3,21 +3,28 @@ asm(".code16gcc\njmp $0, $main"); /* space for additional code */ -char WRITE_CHARACTER_TTY = 0x0E; +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) + // volatile because there is no output, so the function might get optimized + // away + // clang-format off + asm volatile( + "int $0x10;" + ::"a"(command) ); + // clang-format on } +char WRITE_STRING = 0x13; + +void print(char const * const str) { + for(int i = 0; str[i] != '\0'; ++i ) { + put(str[i]); + } +} -void main(void) -{ - put('h'); - put('e'); - put('l'); - put('l'); - put('o'); +void main(void) { + print("Hello!"); } -- cgit v1.2.3-54-g00ecf