Tutorial guide


This tutorial covers the whole process of creating your own tiny computer operating system. It includes the booting module and kernel.

Making your own Operating System

Required tools:

  • emu8086 – assembler, tutorial, and emulator
  • RawWrite for Windows

Usually, when a computer starts it will try to load 512 bytes from sector 1, head 0, cylinder 0 from floppy drive A to 0000h:7C00h and give it control. If this fails, a hard drive is used.

This tutorial covers booting from a floppy drive; the same principle is used to boot from a hard drive. Using a floppy drive has several advantages:

  • You can keep your existing computer operating system software (Windows, DOS...).
  • It's easy to modify the boot record of a floppy drive.

Example of a simple boot program:

; directive to create BOOT file:
#MAKE_BOOT#

; Boot record is loaded at 0000:7C00,
; so inform compiler to make required
; corrections:
ORG 7C00h

; load message address into SI register:
LEA SI, msg

; teletype function id:
MOV AH, 0Eh

print: MOV AL, [SI]
CMP AL, 0
JZ done
INT 10h ; print using teletype.
INC SI
JMP print

; wait for 'any key':
done: MOV AH, 0
INT 16h

; store magic value at 0040h:0072h:
; 0000h - cold boot.
; 1234h - warm boot.
MOV AX, 0040h
MOV DS, AX
MOV w.[0072h], 0000h ; cold boot.

JMP 0FFFFh:0000h ; reboot!

new_line EQU 13, 10

msg DB 'Hello This is My First Boot Program!'
DB new_line, 'Press any key to reboot', 0

Copy the above example to the emu8086 source editor and press Compile and Emulate. The emulator automatically loads the .boot file to 0000h:7C00h.

You can run it like a regular program, or you can use the Virtual Drive menu to Write 512 bytes at 7C00h to Boot Sector of the virtual floppy drive (the FLOPPY_0 file in the emulator's folder).

After writing your program to the virtual floppy drive, you can select Boot from Floppy from the Virtual Drive menu.

If you are curious, you may write the virtual floppy (FLOPPY_0) or .boot file to a real floppy and boot your computer from it. I recommend using RawWrite for Windows from:
http://uranus.it.swin.edu.au/"jn/linux

(Note that this is not an MS-DOS-compatible boot sector, so it is better to use an empty floppy, although it should be IBM (MS-DOS) formatted.)

.boot files are limited to 512 bytes (sector size), so if your operating system is going to grow over this size, you should use a boot program to load data from other sectors. A good example of a tiny operating system can be downloaded here:

  • micro-os_loader.asm
  • micro-os_kernel.asm
  • emu8086.inc

To create extensions for your operating system (over 512 bytes), you can use .bin files (select BIN Template from the File > New menu).

To write a .bin file to a virtual floppy, select Write .bin file to floppy... from the Virtual Drive menu of the emulator:

write_bin.gif

You can also use this to write .boot files.

Sector at:

cylinder: 0
sector: 1
head: 0

is a boot sector!

A typical floppy drive structure:

floppy.gif

  • A floppy disk has 2 sides, and there are 2 heads (0..1), one for each side; these heads move above the disk.
  • Each side has 80 cylinders (0..79).
  • Each cylinder has 18 sectors (1..18).
  • Each sector has 512 bytes.
  • The total size of a floppy disk is: 2 x 80 x 18 x 512 = 1,474,560 bytes.

Now you know about making computer operating systems.

Copyright © 2002 Alexander Popov Emulation Soft.
All rights reserved.
http://www.geocities.com/emu8086/








Make your own computer operating system


Tutorial guide


This tutorial covers the whole process of creating your own tiny computer operating system. It includes the booting module and kernel.

Making your own Operating System

Required tools:

  • emu8086 – assembler, tutorial, and emulator
  • RawWrite for Windows

Usually, when a computer starts it will try to load 512 bytes from sector 1, head 0, cylinder 0 from floppy drive A to 0000h:7C00h and give it control. If this fails, a hard drive is used.

This tutorial covers booting from a floppy drive; the same principle is used to boot from a hard drive. Using a floppy drive has several advantages:

  • You can keep your existing computer operating system software (Windows, DOS...).
  • It's easy to modify the boot record of a floppy drive.

Example of a simple boot program:

; directive to create BOOT file:
#MAKE_BOOT#

; Boot record is loaded at 0000:7C00,
; so inform compiler to make required
; corrections:
ORG 7C00h

; load message address into SI register:
LEA SI, msg

; teletype function id:
MOV AH, 0Eh

print: MOV AL, [SI]
CMP AL, 0
JZ done
INT 10h ; print using teletype.
INC SI
JMP print

; wait for 'any key':
done: MOV AH, 0
INT 16h

; store magic value at 0040h:0072h:
; 0000h - cold boot.
; 1234h - warm boot.
MOV AX, 0040h
MOV DS, AX
MOV w.[0072h], 0000h ; cold boot.

JMP 0FFFFh:0000h ; reboot!

new_line EQU 13, 10

msg DB 'Hello This is My First Boot Program!'
DB new_line, 'Press any key to reboot', 0

Copy the above example to the emu8086 source editor and press Compile and Emulate. The emulator automatically loads the .boot file to 0000h:7C00h.

You can run it like a regular program, or you can use the Virtual Drive menu to Write 512 bytes at 7C00h to Boot Sector of the virtual floppy drive (the FLOPPY_0 file in the emulator's folder).

After writing your program to the virtual floppy drive, you can select Boot from Floppy from the Virtual Drive menu.

If you are curious, you may write the virtual floppy (FLOPPY_0) or .boot file to a real floppy and boot your computer from it. I recommend using RawWrite for Windows from:
http://uranus.it.swin.edu.au/"jn/linux

(Note that this is not an MS-DOS-compatible boot sector, so it is better to use an empty floppy, although it should be IBM (MS-DOS) formatted.)

.boot files are limited to 512 bytes (sector size), so if your operating system is going to grow over this size, you should use a boot program to load data from other sectors. A good example of a tiny operating system can be downloaded here:

  • micro-os_loader.asm
  • micro-os_kernel.asm
  • emu8086.inc

To create extensions for your operating system (over 512 bytes), you can use .bin files (select BIN Template from the File > New menu).

To write a .bin file to a virtual floppy, select Write .bin file to floppy... from the Virtual Drive menu of the emulator:

write_bin.gif

You can also use this to write .boot files.

Sector at:

cylinder: 0
sector: 1
head: 0

is a boot sector!

A typical floppy drive structure:

floppy.gif

  • A floppy disk has 2 sides, and there are 2 heads (0..1), one for each side; these heads move above the disk.
  • Each side has 80 cylinders (0..79).
  • Each cylinder has 18 sectors (1..18).
  • Each sector has 512 bytes.
  • The total size of a floppy disk is: 2 x 80 x 18 x 512 = 1,474,560 bytes.

Now you know about making computer operating systems.

Copyright © 2002 Alexander Popov Emulation Soft.
All rights reserved.
http://www.geocities.com/emu8086/

Make your own computer operating system

Tutorial guide
Make your own computer operating system
Make your own computer operating system
Recommend to friends
  • gplus
  • pinterest

Comment

Leave comment

Rating