30 days, the first day of self-made operating system merk11

Time:2022-1-14

30 days, the first day of self-made operating system merk11

The self-made operating system is not only because of the experimental homework left by school teachers, but also to deepen their understanding of the details of the operating system.

I’ve worked hard to find some on GoogleA tutorial for novices to develop a simple operating system

The environment used is windows and the virtual environment is QEMU

Books:

Self made operating system in 30 days: People’s Posts and Telecommunications Press

Comparison of GitHub Chinese disk source code:

https://github.com/yourtion/30dayMakeOS

https://github.com/chenganglist/30dayMakeOS

Books PDF Online:

http://file.qijin.tech/ebooks/30 Day self-made operating system_ compressed. pdf

We sincerely thank the providers of the above resources for their help to the fledgling college animals

Notes:

Environment configuration:Binary editor (hex editor)

Vscode, WinHex, Notepad + + or other familiar editors can be used

Assembly instruction learning:

DB: it is the abbreviation of “define byte“, that is, the instruction to write 1 byte directly to the file.You can write strings directly with it

DB   "hello,world"

RESB: it’s an abbreviation of “reserve byte”. If you want to spare 10 bytes from the current address, you can write it as RESB 10, which means that we have reserved these 10 bytes (you can imagine that we have reserved 10 consecutive seats in the right seat train).

DW: similar to DB, it reads 2 bytes at a time

DD: similar to DB, it reads 4 bytes at a time

Dollar sign: here is a variable that can tell us the current number of bytes in this line

RESB     0x1fe-$

Main source code (the part you can try to write):

; hello-os
; TAB=4

;  Standard FAT12 format floppy code

​	DB		0xeb, 0x4e, 0x90
​ 	 DB 		 "MERK11" 		;  Boot sector name (8 bytes)
​ 	 DW 		 five hundred and twelve 				;  Size of each sector (512 bytes required)
​ 	 DB 		 one 				;  Cluster size (must be 1 sector)
​ 	 DW 		 one 				;  Fat start position (generally the first sector)
​ 	 DB 		 two 				;  Number of fat (must be 2)
​ 	 DW 		 two hundred and twenty-four 				;  Root directory size (usually 224 items)
​ 	 DW 		 two thousand eight hundred and eighty 			;  The disk size (must be 2880 sectors 1440 * 1024 / 512)
​ 	 DB 		 0xf0 			;  Disk type (must be 0xf0)
​ 	 DW 		 nine 				;  Length of fat (must be 9 sectors)
​ 	 DW 		 eighteen 				;  A track has several sectors (must be 18)
​ 	 DW 		 two 				;  Number of heads (must be 2)
​ 	 DD 		 0 				;  Partition not used, must be 0
​ 	 DD 		 two thousand eight hundred and eighty 			;  Rewrite disk size once
​ 	 DB 		 0,0,0x29 		;  Meaning unknown (fixed)
​ 	 DD 		 0xffffffff 		;  (possibly) volume label number
​ 	 DB 		 "MERK-OS    " 	;  Name of the disk (must be 11 bytes, not enough space)
​ 	 DB 		 "FAT12   " 		;  Disk format name (must be 8 bytes, not enough space)
​ 	 RESB 	 eighteen 				;  Free 18 bytes first

;  Program subject

​	DB		0xb8, 0x00, 0x00, 0x8e, 0xd0, 0xbc, 0x00, 0x7c
​	DB		0x8e, 0xd8, 0x8e, 0xc0, 0xbe, 0x74, 0x7c, 0x8a
​	DB		0x04, 0x83, 0xc6, 0x01, 0x3c, 0x00, 0x74, 0x09
​	DB		0xb4, 0x0e, 0xbb, 0x0f, 0x00, 0xcd, 0x10, 0xeb
​	DB		0xee, 0xf4, 0xeb, 0xfd

;  Information display section

​ 	 DB 		 0x0a, 0x0a 		;  Wrap twice
​	DB		"It is impossible to manufacture or imitate love."
​ 	 DB 		 0x0a 			;  Line feed
​	DB		0

​ 	 RESB 	 0x1fe-$ 			;  Fill in 0x00 until 0x001fe

​	DB		0x55, 0xaa

;  Output outside the boot sector

​	DB		0xf0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00
​	RESB	4600
​	DB		0xf0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00
​	RESB	1469432