Initial commit
This commit is contained in:
commit
ad942b3d8b
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*.bin
|
||||
*.img
|
8
Makefile
Normal file
8
Makefile
Normal file
@ -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 $@
|
38
boot.asm
Normal file
38
boot.asm
Normal file
@ -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
|
28
kernel.asm
Normal file
28
kernel.asm
Normal file
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user