But I'm stuck at the comparison step :
- How to creat a filetable ( I found an example but not clear :s ) {file1-sector,file2-sector,…,filen-sector,}
- Which format should be the file
- Since I've loaded the filetable at 0x2000 in the bootloader , how to put the file at this adress
- Is there a relation between a sector and a segment ? If yes, can someone explain it to me
Here is my code :
Bootloader.asm
Code: Select all
%define drive_number 0
[bits 16]
[org 0x7C00]
boot : jmp start
print_char:
mov ah, 0x0E
mov bh, 0x00
mov bl, 0x03
int 0x10
ret
print_string:
mov al, [si]
inc si
call print_char
or al, al
jz done
jmp print_string
done:
ret
reset_drive:
mov si, reset_drive_start_msg
call print_string
mov ah, 00h
mov dl, drive_number
jc reset_drive_fail
mov si, reset_drive_success_msg
call print_string
ret
reset_drive_fail:
mov si, reset_drive_fail_msg
call print_string
jmp reset_drive
boot_kernel:
mov si, load_kernel_msg
call print_string
mov si, 0x00
;os load
mov ax, 0x1000
mov es, ax
xor bx, bx
mov ah, 0x02
mov al, 1
mov ch, 0
mov cl, 2
mov dh, 0
mov dl, drive_number
int 0x13
mov ax, 0x2000
mov es, ax
xor bx, bx
mov ah, 0x02
mov al, 1
mov ch, 0
mov cl, 2
mov dh, 0
mov dl, drive_number
int 0x13
jc boot_kernel
push es
push bx
mov si, load_kernel_success_msg
call print_string
retf
start:
mov si, start_msg
call print_string
call reset_drive
call boot_kernel
jmp 1000:0x00
start_msg db ' [-] Bootloader has been started !', 0x0D, 0x0A, 0
reset_drive_start_msg db '[-] Trying to reset the disk drive...', 0x0D, 0x0A, 0
reset_drive_success_msg db '[-] Disk drive resetted...[OK]', 0x0D, 0x0A, 0
reset_drive_fail_msg db '[-] Disk drive not resetted...[!]', 0x0D, 0x0A, 0,'Retrying to reset the disk drive...', 0x0D, 0x0A, 0
load_kernel_msg db '[-] Trying to load the kernel...', 0x0D, 0x0A, 0
load_kernel_success_msg db '[-] Kernel loaded...[OK]', 0x0D, 0x0A, 0
load_kernel_fail_msg db '[-] Kernel not loaded...[!]', 0x0D, 0x0A, 0,'Retrying to load the kernel...', 0x0D, 0x0A, 0
TIMES 510 - ($-$$) db 0
dw 0xAA55
Code: Select all
kernel:
jmp k_main
print_string:
still_printing:
lodsb
or al, al
jz print_string_done
mov ah, 0x0E
int 0x10
jmp still_printing
print_string_done:
ret
shell_prompt:
mov si, shellSym
call print_string
push command
call read_command
jmp shell_prompt
read_command:
pusha
mov bp, sp
cld
mov byte [ccount], 0
mov di, [bp+18]
still_reading:
mov ah, 0
int 16h
cmp al, 0dh
jz done_read_command
mov ah, 0x0E
mov bx, 0
int 10h
stosb
inc byte [ccount]
jmp still_reading
done_read_command:
mov si, 0000000000000000
mov si, lj
call print_string
mov sp, bp
popa
ret
k_main:
push cs
pop ds
mov si, welcomeMsg
call print_string
call shell_prompt
welcomeMsg db "Welcome to B.S Operating System... Whats up ! ",10,13,10,13,0
shellSym db ">>",0
ccount dw 0
command times 30 db 0
lj db 10,13,0
TIMES 512 - ($-$$) db 0
Thanks for helping me