Add a disk description table to the bootloader in anticipation of file system support and do some general tweaking.

This commit is contained in:
CrazyEttin 2021-06-01 21:31:20 +03:00
parent 843c018510
commit e791c67665
9 changed files with 66 additions and 32 deletions

View File

@ -6,9 +6,9 @@ then
fi fi
cd src/ cd src/
nasm boot.asm -f bin -o ../build/boot.bin nasm boot.asm -f bin -O0 -o ../build/boot.bin
nasm os.asm -f bin -o ../build/os.bin nasm system.asm -f bin -O0 -o ../build/system.bin
cd ../build/ cd ../build/
cat boot.bin os.bin > EttinOS.img cat boot.bin system.bin > EttinOS.img
rm boot.bin os.bin rm boot.bin system.bin

View File

View File

@ -1,5 +1,26 @@
[ORG 0x7c00] [ORG 0x7c00]
jmp 0:start jmp 0:start
nop
;Disk description table
db "EttinOS " ;Disk label
dw 0x200 ;Bytes per sector
db 0x1 ;Sectors per cluster
dw 0x1 ;Sectors reserved for the boot record
db 0x2 ;Number of copies of the FAT
dw 0xe0 ;Number of directory entries
dw 0xb40 ;Number of logical sectors
db 0xf0 ;Media descriptor type
dw 0x9 ;Sectors per FAT
dw 0x12 ;Sectors per track
dw 0x2 ;Number of heads
dd 0x0 ;Number of hidden sectors
dd 0x0 ;Number of LBA sectors
dw 0x0 ;Drive number
db 0x29 ;Drive signature
dd 0x0 ;Volume ID
db "EttinOS " ;Volume label
db "FAT12 " ;File system type
start: start:
@ -7,6 +28,7 @@ start:
mov ax, 0x0 mov ax, 0x0
mov ds, ax mov ds, ax
;Load the system
;Set the source ;Set the source
mov dh, 0x0 mov dh, 0x0
mov ch, 0x0 mov ch, 0x0
@ -21,7 +43,7 @@ mov al, 0x20
mov ah, 0x2 mov ah, 0x2
int 0x13 int 0x13
;Boot ;Boot the system
jmp 0x1000:0 jmp 0x1000:0
;Padding ;Padding

View File

@ -5,7 +5,7 @@ echo:
;Read a string ;Read a string
mov di, buffer mov di, buffer
mov al, 0xff mov al, 0xff
call readstr call readln
;Check for an empty string ;Check for an empty string
cmp byte [buffer], 0x0 cmp byte [buffer], 0x0

View File

@ -1,4 +1,4 @@
;Reads a keypress and prints its keycode. ;Reads a keypress and prints its BIOS code.
keycode: keycode:

11
src/newline.inc Normal file
View File

@ -0,0 +1,11 @@
;Prints a newline
newline:
mov si, .newline
call printstr
ret
.newline:
db 0xd, 0xa, 0x0

View File

@ -1,14 +1,11 @@
;Prints a line from si until a null. ;Prints a string from si until a null followed by a newline.
println: println:
;Print a string ;Print the string
call printstr call printstr
;Print a newline ;Print a newline
mov si, .newline call newline
call printstr
ret ret
.newline:
db 0xd, 0xa, 0x0

View File

@ -1,6 +1,6 @@
;Reads a string of at most al characters to di. ;Reads a string of at most al characters to di until a return and prints a newline.
readstr: readln:
;Store the length ;Store the length
mov [.length], al mov [.length], al
@ -161,8 +161,7 @@ mov ah, 0x2
mov dh, [.lastln] mov dh, [.lastln]
int 0x10 int 0x10
;Print a newline ;Print a newline
mov si, .newline call newline
call printstr
ret ret
@ -174,6 +173,3 @@ db 0x0
.lastln: .lastln:
db 0x0 db 0x0
.newline:
db 0xd, 0xa, 0x0

View File

@ -3,7 +3,8 @@ jmp start
;Calls ;Calls
%include "printstr.inc" %include "printstr.inc"
%include "println.inc" %include "println.inc"
%include "readstr.inc" ;Under construction %include "readln.inc"
%include "newline.inc"
%include "cmpstr.inc" %include "cmpstr.inc"
%include "byte2hexstr.inc" %include "byte2hexstr.inc"
@ -37,48 +38,55 @@ call printstr
;Read a command ;Read a command
mov di, buffer mov di, buffer
mov al, 0xff mov al, 0xff
call readstr call readln
exec: exec:
;No command ;Identify and execute the command
;Check for no command
cmp byte [buffer], 0x0 cmp byte [buffer], 0x0
je loop je loop
.echo: .echo:
;Check for the command ;Check
mov si, buffer mov si, buffer
mov di, cmd.echo mov di, cmd.echo
call cmpstr call cmpstr
jnc .hello jnc .hello
;Execute the command ;Execute
call echo call echo
jmp loop jmp loop
.hello: .hello:
;Check for the command ;Check
mov si, buffer mov si, buffer
mov di, cmd.hello mov di, cmd.hello
call cmpstr call cmpstr
jnc .help jnc .help
;Execute the command ;Execute
call hello call hello
jmp loop jmp loop
.help: .help:
;Check for the command ;Check
mov si, buffer mov si, buffer
mov di, cmd.help mov di, cmd.help
call cmpstr call cmpstr
jnc .keycode jnc .keycode
;Execute the command ;Execute
call help call help
jmp loop jmp loop
.keycode: .keycode:
;Check for the command ;Check
mov si, buffer mov si, buffer
mov di, cmd.keycode mov di, cmd.keycode
call cmpstr call cmpstr
jnc .error jnc .error
;Execute the command ;Execute
call keycode call keycode
jmp loop jmp loop
.error: .error:
mov si, error mov si, error
call println call println