Permalink
Browse files

first commit

  • Loading branch information...
0 parents commit 8be03bd1bd933c831bf65d23cea13a55515baeec @yyu committed Nov 18, 2011
Showing with 84 additions and 0 deletions.
  1. +8 −0 Makefile
  2. +33 −0 README.rst
  3. BIN a.img.gz
  4. +25 −0 bochsrc
  5. +18 −0 boot.asm
@@ -0,0 +1,8 @@
+run :
+ gzip -cd a.img.gz > a.img
+ nasm boot.asm -o boot.bin
+ dd if=boot.bin of=a.img bs=512 count=1 conv=notrunc
+ bochs
+
+clean :
+ rm -f a.img boot.bin
@@ -0,0 +1,33 @@
+Operating System From Scratch
+-----------------------------
+
+Step 01: A smallest "OS"
+````````````````````````
+
+Let's begin with a simplest boot sector. You'll see how easy it is to get started!
+
+Here we go:
+
++ Install nasm_ the assembly compiler and bochs_ the emulator
+
++ Clone me (we're in GitHub, aren't we)::
+
+ $ git clone https://github.com/yyu/osfs01.git
+
++ Run your smallest "OS" right now::
+
+ $ cd osfs01
+ $ make
+
+ Guess what? It's running!
+
+ .. 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
+
+ The screen is a little messy but you can see the red "Hello, OS world!", which means our boot sector works!
+
+`‹prev`_ `next›`_
+
+.. _nasm: http://nasm.us/
+.. _bochs: http://bochs.sourceforge.net/
+.. _`‹prev`: https://github.com/yyu/osfs00
+.. _`next›`: https://github.com/yyu/osfs02
BIN a.img.gz
Binary file not shown.
25 bochsrc
@@ -0,0 +1,25 @@
+###############################################################
+# Configuration file for Bochs
+###############################################################
+
+# how much memory the emulated machine will have
+megs: 32
+
+# filename of ROM images
+romimage: file=/usr/share/bochs/BIOS-bochs-latest
+vgaromimage: file=/usr/share/vgabios/vgabios.bin
+
+# what disk images will be used
+floppya: 1_44=a.img, status=inserted
+
+# choose the boot disk.
+boot: floppy
+
+# where do we send log messages?
+# log: bochsout.txt
+
+# disable the mouse
+mouse: enabled=0
+
+# enable key mapping, using US layout as default.
+keyboard_mapping: enabled=1, map=/usr/share/bochs/keymaps/x11-pc-us.map
@@ -0,0 +1,18 @@
+ org 07c00h ; where the code will be running
+ mov ax, cs
+ mov ds, ax
+ mov es, ax
+ call DispStr ; let's display a string
+ jmp $ ; and loop forever
+DispStr:
+ mov ax, BootMessage
+ mov bp, ax ; ES:BP = string address
+ mov cx, 16 ; CX = string length
+ mov ax, 01301h ; AH = 13, AL = 01h
+ mov bx, 000ch ; RED/BLACK
+ mov dl, 0
+ int 10h
+ ret
+BootMessage: db "Hello, OS world!"
+times 510-($-$$) db 0 ; fill zeros to make it exactly 512 bytes
+dw 0xaa55 ; boot record signature

1 comment on commit 8be03bd

加了这么多,是什么用意?

Please sign in to comment.