aboutsummaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authorkotorifan <kotorifan05@gmail.com>2026-03-08 15:33:02 +0100
committerkotorifan <kotorifan05@gmail.com>2026-03-08 15:33:02 +0100
commitceedd4f2c7e990162f1b619f0d60471eea3aed1f (patch)
tree640ffbfcb9428624b6386d45d28db35d9ccac756 /src/common
parentf81dee10ef19f0c82eb89d0e528bcbfb7a38b016 (diff)
downloadkotori-os-ceedd4f2c7e990162f1b619f0d60471eea3aed1f.tar.gz
Made a common directory, moved the protmode print there
Diffstat (limited to 'src/common')
-rw-r--r--src/common/common.asm27
-rw-r--r--src/common/common.protmode.clear.asm13
-rw-r--r--src/common/common.protmode.print.asm35
3 files changed, 75 insertions, 0 deletions
diff --git a/src/common/common.asm b/src/common/common.asm
new file mode 100644
index 0000000..a98ef67
--- /dev/null
+++ b/src/common/common.asm
@@ -0,0 +1,27 @@
+;; common.asm
+%ifndef COMMON_ASM
+%define COMMON_ASM
+
+;; Real mode constants
+%define READ_SECTORS_NUM 16
+%define BOOT_LOAD_ADDR 0x7c00
+%define STAGE2_ADDR 0x7e00
+%define SECTOR_SIZE 512
+%define STACK_ADDR 0x9c00
+
+;; Mostly kernel and protected mode constants
+%define VGA_COLOR_BLACK 0
+%define VGA_COLOR_GREEN 2
+%define VGA_COLOR_RED 4
+%define VGA_WHITE_ON_BLACK 0x0f20
+%define VGA_BUFFER 0xb8000
+%define VGA_SCREEN_X 80
+%define VGA_SCREEN_Y 25
+%define VGA_SCREEN (VGA_SCREEN_X*VGA_SCREEN_Y)
+
+;; Forth-specific constants
+%define FS_DATA_STACK 0x80000
+%define FS_RET_STACK 0x90000
+%define FS_DICT_BASE 0xa0000
+
+%endif
diff --git a/src/common/common.protmode.clear.asm b/src/common/common.protmode.clear.asm
new file mode 100644
index 0000000..47cb980
--- /dev/null
+++ b/src/common/common.protmode.clear.asm
@@ -0,0 +1,13 @@
+;; common.protmode.print.asm
+
+%include "common.asm"
+
+_clear_screen:
+ mov edi, VGA_BUFFER
+ mov ecx, VGA_SCREEN
+ mov ax, VGA_WHITE_ON_BLACK
+.clear:
+ mov [edi], eax
+ add edi, 2
+ loop .clear
+ ret
diff --git a/src/common/common.protmode.print.asm b/src/common/common.protmode.print.asm
new file mode 100644
index 0000000..5995e69
--- /dev/null
+++ b/src/common/common.protmode.print.asm
@@ -0,0 +1,35 @@
+;; common.protmode.print.asm
+
+%include "common.asm"
+
+_print_string_pm_vga:
+ pusha
+ mov edi, VGA_BUFFER
+ mov ah, WB_COLOR
+ xor ecx, ecx
+ xor edx, edx
+
+.print_loop:
+ lodsb
+ 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
+
+;; Advance cursor
+ inc cl
+ cmp cl, 80
+ jb .print_loop
+ xor cl, cl
+ inc dl
+
+ jmp .print_loop
+
+.done:
+ popa
+ ret