Hi everyones!

I have explore and development on many programming languages as C++, python, perl, java(a little bit) and Assembly (a little bit),and web languages like html, javascript(a little bit) and PHP. Now I'm wanna create my own OS.
My OS will have a simple boot file as starting up a command prompt as reading
a main script file as running all other stript files ass will build the hole operating system.

the biggest problem is, I don't now how to build the boot sector.
I've try to create a assembly boot file and convert it to a .bin file, as was successed.
the plan is to develop my OS on a memory stick and test it with restart the computer,
press F12 to change boot order and choose my memory stick to start and see my OS.

it's the last thing, that write the bin file to memory stick, which is so hard :'(
it will no work to just format the memory stick and put the bin file there.
and ive try to run NASM debbuger and write the boot file in that way, but it just
write a message "read-only, can't write to disc A:", but the memory stick is E::confused:
and then, I am little bad on assembly, can't Im coding the kernel in C++?

then I'm think that i can install freeDOS on memory stick, so Im can create
my OS based on FreeDOS, but Im not really cure that I can install it without losing windows!:S is a memory stick even a good plattform for my own OS, or must I buy a new computer to test my OS?

thankyou everybody as answer:)! Im so less to read hundred of tutorials and download
a lot of junk programs that don't help me a shit to make my OS:@!!!

here is one boot sector code I'm downloaded on internet and tested. it don't work at all
on my computer

; ==================================================================
; The Mike Operating System bootloader
; Copyright (C) 2006 - 2010 MikeOS Developers -- see doc/LICENSE.TXT
; Based on a free boot loader by E Dehling. It scans the FAT12
; floppy for KERNEL.BIN (the MikeOS kernel), loads it and executes it.
; This must grow no larger than 512 bytes (one sector), with the final
; two bytes being the boot signature (AA55h). Note that in FAT12,
; a cluster is the same as a sector: 512 bytes.
; ==================================================================

	BITS 16

	jmp short bootloader_start	; Jump past disk description section
	nop				; Pad out before disk description

; ------------------------------------------------------------------
; Disk description table, to make it a valid floppy
; Note: some of these values are hard-coded in the source!
; Values are those used by IBM for 1.44 MB, 3.5" diskette

OEMLabel		db "MIKEBOOT"	; Disk label
BytesPerSector		dw 512		; Bytes per sector
SectorsPerCluster	db 1		; Sectors per cluster
ReservedForBoot		dw 1		; Reserved sectors for boot record
NumberOfFats		db 2		; Number of copies of the FAT
RootDirEntries		dw 224		; Number of entries in root dir
					; (224 * 32 = 7168 = 14 sectors to read)
LogicalSectors		dw 2880		; Number of logical sectors
MediumByte		db 0F0h		; Medium descriptor byte
SectorsPerFat		dw 9		; Sectors per FAT
SectorsPerTrack		dw 18		; Sectors per track (36/cylinder)
Sides			dw 2		; Number of sides/heads
HiddenSectors		dd 0		; Number of hidden sectors
LargeSectors		dd 0		; Number of LBA sectors
DriveNo			dw 0		; Drive No: 0
Signature		db 41		; Drive signature: 41 for floppy
VolumeID		dd 00000000h	; Volume ID: any number
VolumeLabel		db "MIKEOS     "; Volume Label: any 11 chars
FileSystem		db "FAT12   "	; File system type: don't change!

; ------------------------------------------------------------------
; Main bootloader code

	mov ax, 07C0h			; Set up 4K of stack space above buffer
	add ax, 544			; 8k buffer = 512 paragraphs + 32 paragraphs (loader)
	cli				; Disable interrupts while changing stack
	mov ss, ax
	mov sp, 4096
	sti				; Restore interrupts

	mov ax, 07C0h			; Set data segment to where we're loaded
	mov ds, ax

	; NOTE: A few early BIOSes are reported to improperly set DL

	mov byte [bootdev], dl		; Save boot device number

	mov eax, 0			; Needed for some older BIOSes

; First, we need to load the root directory from the disk. Technical details:
; Start of root = ReservedForBoot + NumberOfFats * SectorsPerFat = logical 19
; Number of root = RootDirEntries * 32 bytes/entry / 512 bytes/sector = 14
; Start of user data = (start of root) + (number of root) = logical 33

floppy_ok:				; Ready to read first block of data
	mov ax, 19			; Root dir starts at logical sector 19
	call l2hts

	mov si, buffer			; Set ES:BX to point to our buffer (see end of code)
	mov bx, ds
	mov es, bx
	mov bx, si

	mov ah, 2			; Params for int 13h: read floppy sectors
	mov al, 14			; And read 14 of them

	pusha				; Prepare to enter loop

	popa				; In case registers are altered by int 13h

	stc				; A few BIOSes do not set properly on error
	int 13h				; Read sectors using BIOS

	jnc search_dir			; If read went OK, skip ahead
	call reset_floppy		; Otherwise, reset floppy controller and try again
	jnc read_root_dir		; Floppy reset OK?

	jmp reboot			; If not, fatal double error


	mov ax, ds			; Root dir is now in [buffer]
	mov es, ax			; Set DI to this info
	mov di, buffer

	mov cx, word [RootDirEntries]	; Search all (224) entries
	mov ax, 0			; Searching at offset 0

	xchg cx, dx			; We use CX in the inner loop...

	mov si, kern_filename		; Start searching for kernel filename
	mov cx, 11
	rep cmpsb
	je found_file_to_load		; Pointer DI will be at offset 11

	add ax, 32			; Bump searched entries by 1 (32 bytes per entry)

	mov di, buffer			; Point to next entry
	add di, ax

	xchg dx, cx			; Get the original CX back
	loop next_root_entry

	mov si, file_not_found		; If kernel is not found, bail out
	call print_string
	jmp reboot

found_file_to_load:			; Fetch cluster and load FAT into RAM
	mov ax, word [es:di+0Fh]	; Offset 11 + 15 = 26, contains 1st cluster
	mov word [cluster], ax

	mov ax, 1			; Sector 1 = first sector of first FAT
	call l2hts

	mov di, buffer			; ES:BX points to our buffer
	mov bx, di

	mov ah, 2			; int 13h params: read (FAT) sectors
	mov al, 9			; All 9 sectors of 1st FAT

	pusha				; Prepare to enter loop

	popa				; In case registers are altered by int 13h

	int 13h				; Read sectors using the BIOS

	jnc read_fat_ok			; If read went OK, skip ahead
	call reset_floppy		; Otherwise, reset floppy controller and try again
	jnc read_fat			; Floppy reset OK?

	mov si, disk_error		; If not, print error message and reboot
	call print_string
	jmp reboot			; Fatal double error


	mov ax, 2000h			; Segment where we'll load the kernel
	mov es, ax
	mov bx, 0

	mov ah, 2			; int 13h floppy read params
	mov al, 1

	push ax				; Save in case we (or int calls) lose it

; Now we must load the FAT from the disk. Here's how we find out where it starts:
; FAT cluster 0 = media descriptor = 0F0h
; FAT cluster 1 = filler cluster = 0FFh
; Cluster start = ((cluster number) - 2) * SectorsPerCluster + (start of user)
;               = (cluster number) + 31

	mov ax, word [cluster]		; Convert sector to logical
	add ax, 31

	call l2hts			; Make appropriate params for int 13h

	mov ax, 2000h			; Set buffer past what we've already read
	mov es, ax
	mov bx, word [pointer]

	pop ax				; Save in case we (or int calls) lose it
	push ax

	int 13h

	jnc calculate_next_cluster	; If there's no error...

	call reset_floppy		; Otherwise, reset floppy and retry
	jmp load_file_sector

	; In the FAT, cluster values are stored in 12 bits, so we have to
	; do a bit of maths to work out whether we're dealing with a byte
	; and 4 bits of the next byte -- or the last 4 bits of one byte
	; and then the subsequent byte!

	mov ax, [cluster]
	mov dx, 0
	mov bx, 3
	mul bx
	mov bx, 2
	div bx				; DX = [cluster] mod 2
	mov si, buffer
	add si, ax			; AX = word in FAT for the 12 bit entry
	mov ax, word [ds:si]

	or dx, dx			; If DX = 0 [cluster] is even; if DX = 1 then it's odd

	jz even				; If [cluster] is even, drop last 4 bits of word
					; with next cluster; if odd, drop first 4 bits

	shr ax, 4			; Shift out first 4 bits (they belong to another entry)
	jmp short next_cluster_cont

	and ax, 0FFFh			; Mask out final 4 bits

	mov word [cluster], ax		; Store cluster

	cmp ax, 0FF8h			; FF8h = end of file marker in FAT12
	jae end

	add word [pointer], 512		; Increase buffer pointer 1 sector length
	jmp load_file_sector

end:					; We've got the file to load!
	pop ax				; Clean up the stack (AX was pushed earlier)
	mov dl, byte [bootdev]		; Provide kernel with boot device info

	jmp 2000h:0000h			; Jump to entry point of loaded kernel!

; ------------------------------------------------------------------

	mov ax, 0
	int 16h				; Wait for keystroke
	mov ax, 0
	int 19h				; Reboot the system

print_string:				; Output string in SI to screen

	mov ah, 0Eh			; int 10h teletype function

	lodsb				; Get char from string
	cmp al, 0
	je .done			; If char is zero, end of string
	int 10h				; Otherwise, print it
	jmp short .repeat


reset_floppy:		; IN: [bootdev] = boot device; OUT: carry set on error
	push ax
	push dx
	mov ax, 0
	mov dl, byte [bootdev]
	int 13h
	pop dx
	pop ax

l2hts:			; Calculate head, track and sector settings for int 13h
			; IN: logical sector in AX, OUT: correct registers for int 13h
	push bx
	push ax

	mov bx, ax			; Save logical sector

	mov dx, 0			; First the sector
	div word [SectorsPerTrack]
	add dl, 01h			; Physical sectors start at 1
	mov cl, dl			; Sectors belong in CL for int 13h
	mov ax, bx

	mov dx, 0			; Now calculate the head
	div word [SectorsPerTrack]
	mov dx, 0
	div word [Sides]
	mov dh, dl			; Head/side
	mov ch, al			; Track

	pop ax
	pop bx

	mov dl, byte [bootdev]		; Set correct device


; ------------------------------------------------------------------

	kern_filename	db "KERNEL  BIN"	; MikeOS kernel filename

	disk_error	db "Floppy error! Press any key...", 0
	file_not_found	db "KERNEL.BIN not found!", 0

	bootdev		db 0 	; Boot device number
	cluster		dw 0 	; Cluster of the file we want to load
	pointer		dw 0 	; Pointer into Buffer, for loading kernel

; ------------------------------------------------------------------

	times 510-($-$$) db 0	; Pad remainder of boot sector with zeros
	dw 0AA55h		; Boot signature (DO NOT CHANGE!)

buffer:				; Disk buffer begins (8k after this, stack starts)

; ==================================================================
6 Years
Discussion Span
Last Post by muazzamalikazmi5

I'm sorry I can't answer your question, but do you know where I can learn everything you know; I'm inspired :) :D


I'm sorry I can't answer your question, but do you know where I can learn everything you know; I'm inspired :) :D

C/C++: you can download Dev C++ or Codeblock to start programming in C/C++. with
dev C++, it will folowing a tutorial in C. if you want to see other tutorial,
chect websites as cplusplus.com or
with C or C++, you can programming console applications and windows applications
for harder. the most operating systems is coded in C or C++.

Python: download python on www.python.org to download python. when you install python,
you will have a python shell, as can running python files or python commands
directly, just like the windows commandprompt, but as running python, not batch.
Python is a very powerful language and I'm recommented you to start with this
language because it's so easy and powerfull language.
you can search in google for thousend of libraries to make python script that
can record sound, steer a robot via bluetooth and even webcam.
note that you can only running these files in computers with python and
included libraries installed.

Java: is the hardest language to create the enviroment for it. but I can help you there:
1: download and install SDK or JDK latest version.
2: search the map in java directory. you will find programs like javac and java
in it.
3: copy the directory path and put it into system enviroment variable PATH
(mail me if you have problem).
4: restart the computer(system variables in windows must restarted for these variables will work).

now you can code java files and compile and run it with write in command prompt:
javac ello.java
java ello

now the javafile is running. the cool thing with command prompt is that
most commands, like REM or JAVAC is programs in directory paths stored in
PATH variable. so you can make own commands in command prompt by
create the map there you will have your programs, insert the path
in PATH variable and restart the computer. now you have a map to put in your programs.
if you are interest to coding java, search java tutorial in google
so you can learn java. you can then download java ME platform and make mobile applications. that im not have done get. but java is a lot easier then C or C++

Small Basic: is a very easy programming language. you can download small basic an then,
you cam start making console, windows applications and media player.
ask me, and Im send you avanced programs coded in small basic. it was the first
programming language I'm learned.

I hope you will have some development in future. any questions so mail me:P


Usually you would use a virtual machine such as Bochs or QEMU for testing because it is easier than restarting and it will stop you from accidentally damaging hardware.

Once you find a virtual machine that you like you will need to make a disk image of some sort (usually floppy for something like this) and copy boot.bin into the boot sector of this image. Make sure it is a binary file (NOT ELF or PE) and that it has the boot signature in it's last two bytes.

Depending on what system you are using there are different pieces of software you can use to accomplish this. If you are using windows then you can check out this.

Another useful site is http://www.osdev.org



sorry , it seems that i can not help you ,but i would show you my own routing system, based on LINUX. if you wish , we could send messages privately


It is easy to write bin file to USB Stick If you're using linux.
Just open terminal and type:
sudo if=bootload.bin of=/dev/sdb.
If you have not linux download ubuntu and install it on virtual box or vmware.
note: first copy bootload.bin to home directory

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.