Issue with VGA memory after booting to DIY kernel

113 Views Asked by At

This is the structure of my project :

  • "boot.asm" : enters 64-bit mode, make a CHS read and load "kernel" to 0x100000, then jmp to 0x100000
  • "kernel.asm"

This is "kernel.asm" :

   [bits 64]
   msg:   db      "K"
   mov al, [msg]
   mov ah, 3 ; cyan
   mov word [0xb8000], ax
   jmp $

This code works when is put in "boot.asm". But only prints strange glyphs or an "S" when is put in "kernel.asm"... I don't know why. The problem seems to be with "msg" declaration. For example, when I replace " msg: db "K" " by " msg equ "K" " then it prints the good char, I can't figure out the problem, do you have any suggestions ?

Cheers,

2

There are 2 best solutions below

0
On

SOLVED : The solution is just to put [org 0x100000] in kernel.asm to mention nasm where to put code, so that it's sure all memory access are in absolut addressing.

2
On

You have forgot to do a jump over msg. Unless the program performs a jump over msg, msg will be interpreted as a command. Try the following code:

[bits 64]
jmp start
msg:   db      "K"
start:
mov al, [msg]
mov ah, 3 ; cyan
mov word [0xb8000], ax
jmp $