From 8b00afe1b255682cf8c219ab44a3d9fc590cc003 Mon Sep 17 00:00:00 2001 From: kotorifan Date: Sun, 8 Mar 2026 16:37:02 +0100 Subject: Clear message at bootup without extra ascii characters --- src/boot/boot.stage2.asm | 10 +++++----- src/common/common.asm | 2 +- src/common/common.protmode.clear.asm | 9 +++++++-- src/common/common.protmode.print.asm | 24 +++++++++++++++--------- src/kernel/kernel.asm | 16 +++++++--------- 5 files changed, 35 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/boot/boot.stage2.asm b/src/boot/boot.stage2.asm index 13d844b..5131786 100644 --- a/src/boot/boot.stage2.asm +++ b/src/boot/boot.stage2.asm @@ -46,10 +46,10 @@ _protected_mode: mov esp, 0x90000 and esp, 0xFFFFFFF0 ; Align to 16-byte boundary - mov esi, boot_protmode_msg - call _print_string_pm_vga + ;; mov esi, boot_protmode_msg + ;; call _print_string_pm_vga - call 0x10000 + jmp CODE_SEG32:0x10000 boot_s2_msg: db "Entering Stage 2", 13, 10, 0 @@ -63,10 +63,10 @@ align 16 DAP_kernel: db 0x10 db 0 - dw 1 ; Number of sectors + dw 16 ; Number of sectors dw 0x0000 dw 0x1000 ; Offset - dq 66 ; Starting sector + dq 66 ; Starting sector %include "boot.stage1.print.asm" %include "boot.stage2.a20.asm" diff --git a/src/common/common.asm b/src/common/common.asm index a98ef67..87444db 100644 --- a/src/common/common.asm +++ b/src/common/common.asm @@ -13,7 +13,7 @@ %define VGA_COLOR_BLACK 0 %define VGA_COLOR_GREEN 2 %define VGA_COLOR_RED 4 -%define VGA_WHITE_ON_BLACK 0x0f20 +%define VGA_WHITE_ON_BLACK 0x0f %define VGA_BUFFER 0xb8000 %define VGA_SCREEN_X 80 %define VGA_SCREEN_Y 25 diff --git a/src/common/common.protmode.clear.asm b/src/common/common.protmode.clear.asm index 47cb980..8d26e2f 100644 --- a/src/common/common.protmode.clear.asm +++ b/src/common/common.protmode.clear.asm @@ -1,13 +1,18 @@ ;; common.protmode.print.asm +%ifndef COMMON_PROTMODE_CLEAR_ASM +%define COMMON_PROTMODE_CLEAR_ASM + %include "common.asm" _clear_screen: mov edi, VGA_BUFFER mov ecx, VGA_SCREEN - mov ax, VGA_WHITE_ON_BLACK + mov ax, 0x0f20 ; Empty char with white on black .clear: - mov [edi], eax + mov [edi], ax add edi, 2 loop .clear ret + +%endif diff --git a/src/common/common.protmode.print.asm b/src/common/common.protmode.print.asm index 5995e69..82ed3f4 100644 --- a/src/common/common.protmode.print.asm +++ b/src/common/common.protmode.print.asm @@ -1,11 +1,13 @@ ;; common.protmode.print.asm +%ifndef COMMON_PROTMODE_PRINT_ASM +%define COMMON_PROTMODE_PRINT_ASM %include "common.asm" _print_string_pm_vga: pusha mov edi, VGA_BUFFER - mov ah, WB_COLOR + mov ah, VGA_WHITE_ON_BLACK xor ecx, ecx xor edx, edx @@ -14,22 +16,26 @@ _print_string_pm_vga: test al, al jz .done - push eax - mov eax, edx - imul eax, eax, 160 - lea edi, [VGA_BUFFER + eax] - lea edi, [edi + ecx * 2] - pop eax + mov ebx, edx + imul ebx, ebx, 160 + lea ebx, [VGA_BUFFER + ebx + ecx * 2] + + mov ah, VGA_WHITE_ON_BLACK + mov [ebx], ax ;; Advance cursor inc cl - cmp cl, 80 - jb .print_loop + cmp cl, 80 ; Check if screen is full X pos + jne .print_loop xor cl, cl inc dl + cmp dl, 25 + jb .print_loop ; Check if screen is full Y pos jmp .print_loop .done: popa ret + +%endif diff --git a/src/kernel/kernel.asm b/src/kernel/kernel.asm index 022a93d..ca7339e 100644 --- a/src/kernel/kernel.asm +++ b/src/kernel/kernel.asm @@ -2,21 +2,19 @@ [bits 32] [org 0x10000] -%include "common.asm" -%include "common.protmode.print.asm" -%include "common.protmode.clear.asm" - _kernel_entry: cli ; No interrupts yet - mov ebp, RET_STACK - mov esp, DATA_STACK call _clear_screen - call _show_welcome_msg + mov esi, welcome_msg + call _print_string_pm_vga .halt: hlt jmp .halt welcome_msg: - db "Welcome...", 13, 10, 0 - + db "Welcome...", 0 + +%include "common.asm" +%include "common.protmode.print.asm" +%include "common.protmode.clear.asm" -- cgit v1.3