summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Zabka <zabkaste@hu-berlin.de>2020-04-29 16:29:00 +0200
committerStefan Zabka <zabkaste@hu-berlin.de>2020-04-29 16:29:00 +0200
commitbc48fa46034d4bf2adcdfc94ee64b385b0e4a494 (patch)
treef284a3cb375d0bce262597627bfede4642b16da1
parent5b6b88db808fea8797113397e21f01184d3fd4cb (diff)
downloadbetriebssysteme-bc48fa46034d4bf2adcdfc94ee64b385b0e4a494.tar.gz
betriebssysteme-bc48fa46034d4bf2adcdfc94ee64b385b0e4a494.zip
Wrote print()
-rw-r--r--01_exercise/bootloader.c29
1 files 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!");
}