Jump from bootloader to the kernel - Assembly x86_64

54 views Asked by At

I want to make a text-os only with assembly. I created a simple bootloader, but now I don't know how to start my kernel. Can you please help me with any example (if it's possible with a practical example)?

The current code:

boot.asm

BITS 16
ORG 0x7C00

;+--------------------------------+
mov ax, 0x3 ; Set text video mode |
int 0x10    ;                     |
;+--------------------------------+

;+--------------+
mov ah, 0x02 ;  |
xor dl, dl   ;  |
xor dh, dh   ;  |
int 0x10     ;  |
;+--------------+

;+----------------+
mov ax, 0xb800 ;  |
mov es, ax     ;  |
;+----------------+

;+-------------------------------------------------------+
mov ah, 0x02     ; FG = Green - BG = Black               |
mov si, msg_1    ;                                       |
xor di, di       ; 'di' = 0                              |
loop:            ;                                       |
    lodsb        ; Carica si 'in' 'al' e incrementa 'si' |
    or al, al    ; Controlla se 'al' รจ uguale a zero     |
    jz continue  ; jz = 'jump if zero'                   |
    stosw        ; Store in Video Memory                 |
jmp loop         ;                                       |
;+-------------------------------------------------------+

continue:

;+--------------+
mov ah, 0x02 ;  |
mov dl, 37   ;  |
int 0x10     ;  |
;+--------------+

;+-------------------------+
finish: ;                  |
    cli ; Clear Interrupts |
    hlt ; Halt the CPU     |
;+-------------------------+

msg_1: db "Il SO e' stato caricato con successo!", 0

times 510 - ($ - $$) db 0
dw 0xAA55

Makefile

compile:
    nasm boot.asm -o boot.bin
run:
    qemu-system-x86_64 boot.bin
0

There are 0 answers