diff --git a/make.sh b/make.sh index c2a8c12..3724e0c 100755 --- a/make.sh +++ b/make.sh @@ -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 diff --git a/src/EttinOS.img b/src/EttinOS.img deleted file mode 100644 index e69de29..0000000 diff --git a/src/boot.asm b/src/boot.asm index 55e574f..61f9c67 100644 --- a/src/boot.asm +++ b/src/boot.asm @@ -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 diff --git a/src/echo.inc b/src/echo.inc index ed855aa..c0a40dd 100644 --- a/src/echo.inc +++ b/src/echo.inc @@ -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 diff --git a/src/keycode.inc b/src/keycode.inc index e73fa81..64268d9 100644 --- a/src/keycode.inc +++ b/src/keycode.inc @@ -1,4 +1,4 @@ -;Reads a keypress and prints its keycode. +;Reads a keypress and prints its BIOS code. keycode: diff --git a/src/newline.inc b/src/newline.inc new file mode 100644 index 0000000..1dd912d --- /dev/null +++ b/src/newline.inc @@ -0,0 +1,11 @@ +;Prints a newline + +newline: + +mov si, .newline +call printstr + +ret + +.newline: +db 0xd, 0xa, 0x0 diff --git a/src/println.inc b/src/println.inc index 54e296f..07e8509 100644 --- a/src/println.inc +++ b/src/println.inc @@ -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 diff --git a/src/readstr.inc b/src/readln.inc similarity index 94% rename from src/readstr.inc rename to src/readln.inc index aea9922..55b5b5b 100644 --- a/src/readstr.inc +++ b/src/readln.inc @@ -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 diff --git a/src/os.asm b/src/system.asm similarity index 82% rename from src/os.asm rename to src/system.asm index c10c13a..bed7819 100644 --- a/src/os.asm +++ b/src/system.asm @@ -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