├── Makefile ├── README.rst ├── a.img.gz ├── bochsrc └── boot.asm /Makefile: -------------------------------------------------------------------------------- 1 | run : 2 | gzip -cd a.img.gz > a.img 3 | nasm boot.asm -o boot.bin 4 | dd if=boot.bin of=a.img bs=512 count=1 conv=notrunc 5 | bochs 6 | 7 | clean : 8 | rm -f a.img boot.bin 9 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | Operating System From Scratch 2 | ----------------------------- 3 | 4 | Step 01: A smallest "OS" 5 | ```````````````````````` 6 | 7 | Let's begin with a simplest boot sector. You'll see how easy it is to get started! 8 | 9 | Here we go: 10 | 11 | + Install nasm_ the assembly compiler and bochs_ the emulator 12 | 13 | + Clone me (we're in GitHub, aren't we):: 14 | 15 | $ git clone https://github.com/yyu/osfs01.git 16 | 17 | + Run your smallest "OS" right now:: 18 | 19 | $ cd osfs01 20 | $ make 21 | 22 | Guess what? It's running! 23 | 24 | .. image:: http://osfromscratch.org/snapshots/original/%E5%9B%BE01.01%20%E6%9C%80%E5%B0%8F%E7%9A%84%E2%80%9C%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E2%80%9D.png 25 | 26 | The screen is a little messy but you can see the red "Hello, OS world!", which means our boot sector works! 27 | 28 | `‹prev`_ `next›`_ 29 | 30 | .. _nasm: http://nasm.us/ 31 | .. _bochs: http://bochs.sourceforge.net/ 32 | .. _`‹prev`: https://github.com/yyu/osfs00 33 | .. _`next›`: https://github.com/yyu/osfs02 34 | -------------------------------------------------------------------------------- /a.img.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yyu/osfs01/8be03bd1bd933c831bf65d23cea13a55515baeec/a.img.gz -------------------------------------------------------------------------------- /bochsrc: -------------------------------------------------------------------------------- 1 | ############################################################### 2 | # Configuration file for Bochs 3 | ############################################################### 4 | 5 | # how much memory the emulated machine will have 6 | megs: 32 7 | 8 | # filename of ROM images 9 | romimage: file=/usr/share/bochs/BIOS-bochs-latest 10 | vgaromimage: file=/usr/share/vgabios/vgabios.bin 11 | 12 | # what disk images will be used 13 | floppya: 1_44=a.img, status=inserted 14 | 15 | # choose the boot disk. 16 | boot: floppy 17 | 18 | # where do we send log messages? 19 | # log: bochsout.txt 20 | 21 | # disable the mouse 22 | mouse: enabled=0 23 | 24 | # enable key mapping, using US layout as default. 25 | keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map 26 | -------------------------------------------------------------------------------- /boot.asm: -------------------------------------------------------------------------------- 1 | org 07c00h ; where the code will be running 2 | mov ax, cs 3 | mov ds, ax 4 | mov es, ax 5 | call DispStr ; let's display a string 6 | jmp $ ; and loop forever 7 | DispStr: 8 | mov ax, BootMessage 9 | mov bp, ax ; ES:BP = string address 10 | mov cx, 16 ; CX = string length 11 | mov ax, 01301h ; AH = 13, AL = 01h 12 | mov bx, 000ch ; RED/BLACK 13 | mov dl, 0 14 | int 10h 15 | ret 16 | BootMessage: db "Hello, OS world!" 17 | times 510-($-$$) db 0 ; fill zeros to make it exactly 512 bytes 18 | dw 0xaa55 ; boot record signature 19 | --------------------------------------------------------------------------------