.load 0x2C00 .fixed 1024, 0xFF .entry _kernel0_main .header KERNEL0_BOOT @include <../bios_api.dss> @include @include ## ========================================================================================================================= .data $textCell $test_str "Hello DragonOS! :)" $cursor_x:1 ## ========================================================================================================================= ## ========================================================================================================================= .code _kernel0_main: push DefaultPalette.Black push 1 call $_clear_screen push $test_str push 1 call $_print_string mov [$cursor_x], 0 ## Init Keyboard driver push $_key_pressed ## KeyPressed handler address passed to the _init_keyboard subroutine push 1 call $_init_keyboard _infinite_loop: jmp $_infinite_loop hlt ## ========================================================================================================================= ## ========================================================================================================================= _key_pressed: ## debug_break mov R1, [Keyboard_Registers.KEYCODE] mov ACC, 13 ## Enter jeq $_key_pressed_enter, R1 mov ACC, ASCII.LOWERCASE_A jls $_key_pressed_end, R1 mov ACC, ASCII.LOWERCASE_Z jgr $_key_pressed_end, R1 push R1 mov R2, [$cursor_x] push R2 push 1 push DefaultPalette.Red push 4 call $_print_char inc R2 mov [$cursor_x], R2 jmp $_key_pressed_end _key_pressed_enter: mov [$cursor_x], 0 mov R10, 0x25 int 0x30 jmp $_key_pressed_end _key_pressed_end: ret ## ========================================================================================================================= ## ========================================================================================================================= _print_string: ## _print_string(string* str) arg R1 ## @Param: str movb [$textCell.CoordX], 0 movb [$textCell.CoordY], 0 movb [$textCell.Foreground], DefaultPalette.Blue movb [$textCell.Background], DefaultPalette.Black mov R10, 0x22 mov R8, R1 mov R9, $textCell int 0x30 ret ## ========================================================================================================================= ## ========================================================================================================================= _print_char: ## _print_char(int16 char, int16 x, int16 y, int16 color) arg R1 ## @Param: char arg R2 ## @Param: x arg R3 ## @Param: y arg R4 ## @Param: color movb [$textCell.CoordX], R2 movb [$textCell.CoordY], R3 movb [$textCell.Foreground], R4 movb [$textCell.Background], DefaultPalette.Black movb [$textCell.Character], R1 mov R10, 0x21 mov R9, $textCell int 0x30 ret ## ========================================================================================================================= ## ========================================================================================================================= _clear_screen: ## _clear_screen(int8_t color) arg R1 movb [$textCell.Foreground], R1 movb [$textCell.Background], R1 movb [$textCell.Character], 0x20 mov R10, 0x24 mov R9, $textCell int 0x30 ret ## =========================================================================================================================