first commit

This commit is contained in:
sam 2024-03-07 23:49:36 +13:00
commit eda494ac49
5 changed files with 90 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
ros.img

8
Makefile Normal file
View file

@ -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

5
hcf.asm Normal file
View file

@ -0,0 +1,5 @@
hcf:
cli
.loop:
hlt
jmp .loop

71
stage1.asm Normal file
View file

@ -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"

5
stage2.asm Normal file
View file

@ -0,0 +1,5 @@
stage2:
mov ax, msg_loaded
call puts
msg_loaded: db "Loaded!"