commit eda494ac49758e2ab75f03cf01326cf686221bfb Author: sam Date: Thu Mar 7 23:49:36 2024 +1300 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d9cc23a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +ros.img diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..611474e --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +FLOPPY = ros.img +SRC_FILES = $(cd src && shell find -L * -type f -name '*.asm') + +$(FLOPPY): Makefile $(SRC_FILES) + nasm stage1.asm -o $(FLOPPY) + +run: $(FLOPPY) + qemu-system-i386 -fda $(FLOPPY) -boot a -enable-kvm -cpu host -m 512M diff --git a/hcf.asm b/hcf.asm new file mode 100644 index 0000000..adbb4ff --- /dev/null +++ b/hcf.asm @@ -0,0 +1,5 @@ +hcf: + cli +.loop: + hlt + jmp .loop diff --git a/stage1.asm b/stage1.asm new file mode 100644 index 0000000..91e9555 --- /dev/null +++ b/stage1.asm @@ -0,0 +1,71 @@ +org 0x7c00 +jmp main + +%include "hcf.asm" + +main: + mov ax, msg_checking + call puts + + mov ah, 0 ; reset disk + mov dl, 0 ; disk A + int 0x13 + jc .fail + jmp .success +.fail: + mov ax, msg_fail + call puts + jmp hcf + +.success: + mov ax, msg_success + call puts + + mov ah, 0x2 ; read sectors + mov al, 0x2 ; sector count + mov ch, 0x0 ; cylind + mov cl, 0x2 ; sector index + mov dh, 0x0 ; head + mov dl, 0x0 ; disk A + + mov bx, 0 + mov es, bx + mov bx, stage2 + int 0x13 + jmp stage2 + +puts: + push bx + push di + + mov bx, ax + + mov ah, 0xE + mov di, 0 +.loop: + mov al, [bx + di] + + cmp al, 0 + je .exit + int 0x10 + + cmp al, 0xA + jne .skip + mov al, 0xD + int 0x10 +.skip: + inc di + jmp .loop +.exit: + pop di + pop bx + ret + +msg_checking: db "Checking that Floppy Disk A is mounted... ", 0 +msg_success: db "success!", 0xA, 0 +msg_fail: db "fail!", 0xA, 0 + +times 510 - ($-$$) db 0 +db 0x55, 0xaa + +%include "stage2.asm" diff --git a/stage2.asm b/stage2.asm new file mode 100644 index 0000000..c8c1e9e --- /dev/null +++ b/stage2.asm @@ -0,0 +1,5 @@ +stage2: + mov ax, msg_loaded + call puts + +msg_loaded: db "Loaded!"