Skip to content

Commit d5c6a2a

Browse files
author
Ian Seyler
committed
Cleanup
1 parent 2815623 commit d5c6a2a

File tree

1 file changed

+31
-32
lines changed

1 file changed

+31
-32
lines changed

src/drivers/vga.asm

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
; BareMetal -- a 64-bit OS written in Assembly for x86-64 systems
33
; Copyright (C) 2008-2025 Return Infinity -- see LICENSE.TXT
44
;
5-
; VGA Text mode functions
5+
; VGA text mode Output
66
; =============================================================================
77

88

99
; -----------------------------------------------------------------------------
1010
; vga_init -- Initialize VGA text output
1111
; IN: Nothing
1212
; OUT: Nothing
13-
; All other registers preserved
1413
vga_init:
1514
mov word [vga_Rows], 25
1615
mov word [vga_Cols], 80
@@ -60,36 +59,6 @@ nexttritone:
6059
; -----------------------------------------------------------------------------
6160

6261

63-
; -----------------------------------------------------------------------------
64-
; vga_clear_screen -- Clear the screen
65-
; IN: Nothing
66-
; OUT: All registers preserved
67-
vga_clear_screen:
68-
push rdi
69-
push rcx
70-
push rax
71-
pushfq
72-
73-
; Set cursor to top left corner
74-
mov word [vga_Cursor_Row], 0
75-
mov word [vga_Cursor_Col], 0
76-
77-
cld ; Clear the direction flag as we want to increment through memory
78-
79-
xor ecx, ecx
80-
mov ax, 0x8F20 ; 0x8F for gray background/bright white foreground, 0x20 for space (black) character
81-
mov edi, 0xB8000
82-
mov ecx, 2000 ; 80 x 25
83-
rep stosw ; Clear the screen. Store word in AX to RDI, RCX times
84-
85-
popfq
86-
pop rax
87-
pop rcx
88-
pop rdi
89-
ret
90-
; -----------------------------------------------------------------------------
91-
92-
9362
; -----------------------------------------------------------------------------
9463
; os_inc_cursor -- Increment the cursor by one, scroll if needed
9564
; IN: Nothing
@@ -377,6 +346,36 @@ vga_output_chars_done:
377346
; -----------------------------------------------------------------------------
378347

379348

349+
; -----------------------------------------------------------------------------
350+
; vga_clear_screen -- Clear the screen
351+
; IN: Nothing
352+
; OUT: All registers preserved
353+
vga_clear_screen:
354+
push rdi
355+
push rcx
356+
push rax
357+
pushfq
358+
359+
; Set cursor to top left corner
360+
mov word [vga_Cursor_Row], 0
361+
mov word [vga_Cursor_Col], 0
362+
363+
cld ; Clear the direction flag as we want to increment through memory
364+
365+
xor ecx, ecx
366+
mov ax, 0x8F20 ; 0x8F for gray background/bright white foreground, 0x20 for space (black) character
367+
mov edi, 0xB8000
368+
mov ecx, 2000 ; 80 x 25
369+
rep stosw ; Clear the screen. Store word in AX to RDI, RCX times
370+
371+
popfq
372+
pop rax
373+
pop rcx
374+
pop rdi
375+
ret
376+
; -----------------------------------------------------------------------------
377+
378+
380379
; -----------------------------------------------------------------------------
381380
; vga_draw_line - Draw the line for the rolling output
382381
vga_draw_line:

0 commit comments

Comments
 (0)