commit ad942b3d8b64073527788cecb602fc34a4a41b71 Author: Xnoe Date: Sat Aug 28 07:06:31 2021 +0100 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7cf5001 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.bin +*.img diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..33dc13b --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +disk.img: boot kernel + cat boot.bin kernel.bin > disk.img + +boot.bin: boot.asm + nasm boot.asm -o $@ + +kernel.bin: kernel.asm + nasm kernel.asm -o $@ diff --git a/boot.asm b/boot.asm new file mode 100644 index 0000000..d3c023a --- /dev/null +++ b/boot.asm @@ -0,0 +1,38 @@ +[BITS 16] ;tell the assembler that its a 16 bit code + +mov ax, 7c0h +mov ds, ax + +mov si, _boot_msg +call _boot_print + +mov ah, 02h +mov al, 1 +mov ch, 0 +mov cl, 2 +mov dh, 0 + +mov bx, 2000h +mov es, bx +xor bx, bx +int 13h + +jmp 2000h:0 + +_boot_print: + mov ah, 0eh + mov cx, 1 + mov bh, 0 +_boot_print_loop: + lodsb + cmp al, 0 + je _boot_print_exit + int 10h + jmp _boot_print_loop +_boot_print_exit: + ret + +_boot_msg db "Boot Sector OK!", 13, 10, 0 + +TIMES 510 - ($ - $$) db 0 ;fill the rest of sector with 0 +DW 0xAA55 ; add boot signature at the end of bootloader diff --git a/kernel.asm b/kernel.asm new file mode 100644 index 0000000..70e59c5 --- /dev/null +++ b/kernel.asm @@ -0,0 +1,28 @@ +sect2: + mov ax, 2000h + mov ds, ax + + mov si, msg + call print + + mov si, msg2 + call print + + jmp $ + + msg db "Kernel OK!", 13, 10, 0 + msg2 db "Hello, World!", 13, 10, 0 + +print: + mov ah, 0eh + mov cx, 1 + mov bh, 0 +print_loop: + lodsb + cmp al, 0 + je print_exit + int 10h + jmp print_loop +print_exit: + ret +