From f219bc7fa3add23d4fe8d989d52194c985bcd6d8 Mon Sep 17 00:00:00 2001 From: nub31 Date: Fri, 22 Aug 2025 21:28:06 +0200 Subject: [PATCH] ... --- .clang-format | 18 ++++++++++++++++++ src/boot.asm | 37 +++++++++++++++++++++++++++++++++++++ src/kernel.c | 5 +++++ src/kernel_entry.asm | 5 +++++ 4 files changed, 65 insertions(+) create mode 100644 .clang-format create mode 100644 src/kernel_entry.asm diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..cb5cd48 --- /dev/null +++ b/.clang-format @@ -0,0 +1,18 @@ +IndentWidth: 4 +ColumnLimit: 120 + +# Pointer formatting +DerivePointerAlignment: false +PointerAlignment: Left + +# Function formatting +AllowShortFunctionsOnASingleLine: None + +# Control how short statements are placed +AllowShortBlocksOnASingleLine: Never +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false + +SeparateDefinitionBlocks: Always + +BreakBeforeBraces: Allman diff --git a/src/boot.asm b/src/boot.asm index bc1bd27..abd5548 100644 --- a/src/boot.asm +++ b/src/boot.asm @@ -1,6 +1,32 @@ [org 0x7c00] [bits 16] +KERNEL_LOCATION equ 0x1000 + +mov [BOOT_DISK], dl + +xor ax, ax +mov es, ax +mov ds, ax +mov bp, 0x8000 +mov sp, bp + +mov bx, KERNEL_LOCATION +mov dh, 2 + +mov ah, 0x02 +mov al, dh +mov ch, 0x00 +mov dh, 0x00 +mov cl, 0x02 +mov dl, [BOOT_DISK] +int 0x13 + + +mov ah, 0x0 +mov al, 0x3 +int 0x10 + CODE_SEG equ gdt_code - gdt_start cli @@ -40,6 +66,17 @@ gdt_descriptor: [bits 32] start_protected_mode: + mov ax, DATA_SEG + mov ds, ax + mov ss, ax + mov es, ax + mov fs, ax + mov gs, ax + + mov ebp, 0x90000 + mov esp, ebp + + jmp KERNEL_LOCATION jmp $ diff --git a/src/kernel.c b/src/kernel.c index e69de29..9b6317e 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -0,0 +1,5 @@ +int main(void) +{ + *(char*)0xb8000 = 'A'; + return 0; +} \ No newline at end of file diff --git a/src/kernel_entry.asm b/src/kernel_entry.asm new file mode 100644 index 0000000..7992f82 --- /dev/null +++ b/src/kernel_entry.asm @@ -0,0 +1,5 @@ +section .text + [bits 32] + [extern main] + call main + jmp $ \ No newline at end of file