~kernel/entry.asm
.asm
Assembly
(text/assembly)
bits 32

extern kmain

global set_cursor_pos
global hide_cursor
global show_cursor

; Inputs: rdi = row, rsi = col
set_cursor_pos:
  push    ebp
  mov     ebp, esp

  mov     eax, dword [ebp + 8]    ; eax = row
  mov     ebx, 80
  imul    eax, ebx                ; eax = row * 80
  add     eax, dword [ebp + 12]   ; eax += col
  mov     bx, ax                  ; bx = position (16-bit)

  ; outb(0x3D4, 0x0E);
  mov     dx, 0x3D4
  mov     al, 0x0E
  out     dx, al

  ; outb(0x3D5, (position >> 8) & 0xFF);
  mov     dx, 0x3D5
  mov     al, bh
  out     dx, al

  ; outb(0x3D4, 0x0F);
  mov     dx, 0x3D4
  mov     al, 0x0F
  out     dx, al

  ; outb(0x3D5, position & 0xFF);
  mov     dx, 0x3D5
  mov     al, bl
  out     dx, al

  mov     esp, ebp
  pop     ebp
  ret

; void hide_cursor(void)
hide_cursor:
  ; Read: write index 0x0A, then write data with bit 5 set
  ; For simplicity we don't read current value; we set start = 0x20 (disabled)
  mov     dx, 0x3D4
  mov     al, 0x0A
  out     dx, al

  mov     dx, 0x3D5
  mov     al, 0x20   ; set bit 5 to disable cursor
  out     dx, al

  ret

; void show_cursor(void)
show_cursor:
  ; Restore a typical cursor shape: start = 0 (scanline start)
  mov     dx, 0x3D4
  mov     al, 0x0A
  out     dx, al

  mov     dx, 0x3D5
  mov     al, 0x00    ; cursor start = 0
  out     dx, al

  ; set cursor end (e.g., 15)
  mov     dx, 0x3D4
  mov     al, 0x0B
  out     dx, al

  mov     dx, 0x3D5
  mov     al, 0x0F  ; cursor end = 15 (typical)
  out     dx, al

  ret

section .entry

; void start()
global _start
_start:
	mov esp, kernelStackStart
	call kmain

	.hang:
		cli
		hlt
		jmp .hang

align 16
kernelStackEnd:
	times 16384 db 0
kernelStackStart: