I'm following a tutorial (only to start learning more about Assembly by playing around with code) which is DonkerOSYD. I want to make the kernel load a BIN file.
This is KERNEL.ASM
Code: Select all
BITS 16
Main:
cli
mov ax, 0x0000
mov ss, ax
mov sp, 0xFFFF
sti
mov ax, 2000h
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov [BootDrive], dl
setup_bg:
mov dx, 0
call move_cursor
mov ah, 09h
mov al, ''
mov bh, 0
mov bl, 00000111b
mov cx, 2400
int 10h
mov si, version
call Print
call newline
mov si, copyright
call Print
cmd:
call newline
mov si, prompt
call Print
mov di, input_buffer
mov al, 0
mov cx, 256
rep stosb
mov ax, input_buffer
mov di, input_buffer
.loop:
call keyboard
cmp al, 13 ;ENTER
je .done
cmp al, 8 ;BACKSPACE
je .backspace
jmp .character
.backspace:
mov ah, 0Eh
mov al, 8
int 10h
mov al, 32
int 10h
mov al, 8
int 10h
dec di
jmp .loop
.character:
mov ah, 0Eh
int 10h
stosb
jmp .loop
.done:
mov ax, 0
stosb
call newline
mov si, input_buffer
cmp BYTE [si], 0
je cmd
;All built-in commands
mov di, help_string
call compare
jc help
mov di, help_uc
call compare
jc help
mov di, dir_string
call compare
jc dir
mov di, dir_uc
call compare
jc dir
mov di, exit_string
call compare
jc exit
mov di, exit_uc
call compare
jc exit
;what if it's not a built-in command?
mov si, input_buffer
call Print
mov si, no_command
call Print
jmp cmd
%INCLUDE "variables.asm"
%INCLUDE "functions.asm"
%INCLUDE "cli_commands.asm"
Code: Select all
newline:
pusha
mov ah, 0Eh
mov al, 13
int 10h
mov al, 10
int 10h
popa
ret
Print:
lodsb
cmp al, 0
je Done
mov ah, 0eh
int 10h
jmp Print
Done:
ret
move_cursor:
pusha
mov ah, 02h
mov bh, 0
int 10h
popa
ret
keyboard:
pusha
mov ax, 0
mov ah, 10h
int 16h
mov [.buffer], ax
popa
mov ax, [.buffer]
ret
.buffer dw 0
compare:
pusha
.loop:
mov al, [si]
mov ah, [di]
cmp al, ah
jne .not_equal
cmp al, 0
je .equal
inc si
inc di
jmp .loop
.not_equal:
popa
clc
ret
.equal:
popa
stc
ret
reset_floppy:
mov ax, 0
mov dl, BYTE [BootDrive]
int 13h
ret
convert_sector:
push bx
push ax
mov bx, ax
mov dx, 0
div WORD [.SectorsPerTrack]
add dl, 01h
mov cl, dl
mov ax, bx
mov dx, 0
div WORD [.SectorsPerTrack]
mov dx, 0
div WORD [.Sides]
mov dh, dl
mov ch, al
pop ax
pop bx
mov dl, BYTE [BootDrive]
ret
.SectorsPerTrack dw 18
.Sides dw 2
os_string_uppercase:
pusha
mov si, ax ; Use SI to access string
.more:
cmp byte [si], 0 ; Zero-termination of string?
je .done ; If so, quit
cmp byte [si], 'a' ; In the lower case A to Z range?
jb .noatoz
cmp byte [si], 'z'
ja .noatoz
sub byte [si], 20h ; If so, convert input char to upper case
inc si
jmp .more
.noatoz:
inc si
jmp .more
.done:
popa
ret
Code: Select all
buffer equ 24576
dir:
pusha
mov di, dirlist
call reset_floppy
mov ch, 0
mov cl, 2
mov dh, 1
mov bx, buffer
mov al, 14
mov ah, 2
pusha
load_root_dir:
int 13h
jnc loaded_root_dir
call reset_floppy
jmp load_root_dir
loaded_root_dir:
popa
mov si, buffer
compare_entry:
mov al, [si+11]
cmp al, 0Fh ;Windows marker
je .skip_entry
cmp al, 18h ;Directory marker
je .skip_entry
cmp al, 229 ;deleted file
je .skip_entry
cmp al, 0
je .done
mov dx, si
mov cx, 0
.save_character:
mov BYTE al, [si]
cmp al, ' '
je .space
mov BYTE [di], al
inc di
inc si
inc cx
cmp cx, 8
je .add_dot
cmp cx, 11
je .string_copied
jmp .save_character
.add_dot:
mov BYTE [di], '.'
inc di
jmp .save_character
.space:
inc si
inc cx
cmp cx, 8
je .add_dot
jmp .save_character
.string_copied:
mov BYTE [di], ','
inc di
mov si, dx
.skip_entry:
add si, 32
jmp compare_entry
.done:
mov si, dirlist
mov ah, 0Eh
.print:
lodsb
cmp al, 0
je .done_printing
cmp al, ','
je .comma
int 10h
jmp .print
.comma:
call newline
jmp .print
.done_printing:
popa
jmp cmd
help:
mov si, help_message
call Print
jmp cmd
exit:
mov ax, 5307h
mov cx, 3
mov bx, 1
int 15h
Thanks
Steve.