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
cd src/
nasm boot.asm -f bin -o ../build/boot.bin
nasm os.asm -f bin -o ../build/os.bin
nasm boot.asm -f bin -O0 -o ../build/boot.bin
nasm system.asm -f bin -O0 -o ../build/system.bin
cd ../build/
cat boot.bin os.bin > EttinOS.img
rm boot.bin os.bin
cat boot.bin system.bin > EttinOS.img
rm boot.bin system.bin

View File

View File

@ -1,5 +1,26 @@
[ORG 0x7c00]
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:
@ -7,6 +28,7 @@ start:
mov ax, 0x0
mov ds, ax
;Load the system
;Set the source
mov dh, 0x0
mov ch, 0x0
@ -21,7 +43,7 @@ mov al, 0x20
mov ah, 0x2
int 0x13
;Boot
;Boot the system
jmp 0x1000:0
;Padding

View File

@ -5,7 +5,7 @@ echo:
;Read a string
mov di, buffer
mov al, 0xff
call readstr
call readln
;Check for an empty string
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:

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:
;Print a string
;Print the string
call printstr
;Print a newline
mov si, .newline
call printstr
call newline
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
mov [.length], al
@ -161,8 +161,7 @@ mov ah, 0x2
mov dh, [.lastln]
int 0x10
;Print a newline
mov si, .newline
call printstr
call newline
ret
@ -174,6 +173,3 @@ db 0x0
.lastln:
db 0x0
.newline:
db 0xd, 0xa, 0x0

View File

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