From 298d1be60ce2300b006146a7e117c82b86248fa1 Mon Sep 17 00:00:00 2001 From: Alexander Myltsev Date: Wed, 21 Sep 2022 16:53:45 +0300 Subject: [PATCH] Initial commit --- Makefile | 12 ++++++++++++ README.md | 1 + mbr.S | 28 ++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 Makefile create mode 100644 README.md create mode 100644 mbr.S diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..79aec12 --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ +AS=x86_64-elf-as +LD=x86_64-elf-ld + +run: mbr.bin + qemu-system-i386 -drive format=raw,file=$< + +%.o: %.S + $(AS) $^ -o $@ + +mbr.bin: mbr.o + $(LD) -Ttext=0x7c00 --oformat=binary $^ -o $@ + diff --git a/README.md b/README.md new file mode 100644 index 0000000..ed69b2f --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +Yet Another BootLoader, OS Kernel and Other stuff diff --git a/mbr.S b/mbr.S new file mode 100644 index 0000000..4aceb13 --- /dev/null +++ b/mbr.S @@ -0,0 +1,28 @@ + .code16 + .global _start +_start: #точка входа + mov $banner, %si + call print_string + + jmp . // loop forever + + +print_string: + mov $0x0e, %ah // "teletype output" +repeat: + lodsb // equivalent to mov (%si), %al; inc %si + + test %al, %al + je done + + int $0x10 // bios interrupt + jmp repeat +done: + ret + + . = _start + 256 # pad to 256 bytes +banner: + .asciz "YABLOKO bootloader started\r\n" + + . = _start + 510 # pad to 510 bytes + .byte 0x55, 0xaa # boot sector magic value