![]() |
Help needed to Write fist hello world operating system in pen drive.
I am not much knew to assembly language. I worked on it in my college days. But now i am again starting it after a gap of two years. Lot of things are gone. Except the interest in the simplicity in assembly language. Now i am trying to make a very small operating system of simply printing hello world. I am using pen drive in place of floppy here. the program i am using is
;---------------------------------------------------------------------- ; Simple boot program that prints the letter 'H' ; and then hangs ; Joel Gompert 2001 ; ; Disclaimer: I am not responsible for any results of the use of the contents ; of this file ;---------------------------------------------------------------------- org 0x7c ; This is where BIOS loads the bootloader ; Execution begins here entry: jmp short begin ; jump over the DOS boot record data ; ---------------------------------------------------------------------- ; data portion of the "DOS BOOT RECORD" ; ---------------------------------------------------------------------- brINT13Flag DB 90H ; 0002h - 0EH for INT13 AH=42 READ brOEM DB 'MSDOS5.0' ; 0003h - OEM name & DOS version (8 chars) brBPS DW 512 ; 000Bh - Bytes/sector brSPC DB 1 ; 000Dh - Sectors/cluster brResCount DW 1 ; 000Eh - Reserved (boot) sectors brFATs DB 2 ; 0010h - FAT copies brRootEntries DW 0E0H ; 0011h - Root directory entries brSectorCount DW 2880 ; 0013h - Sectors in volume, < 32MB brMedia DB 240 ; 0015h - Media descriptor brSPF DW 9 ; 0016h - Sectors per FAT brSPH DW 18 ; 0018h - Sectors per track brHPC DW 2 ; 001Ah - Number of Heads brHidden DD 0 ; 001Ch - Hidden sectors brSectors DD 0 ; 0020h - Total number of sectors DB 0 ; 0024h - Physical drive no. DB 0 ; 0025h - Reserved (FAT32) DB 29H ; 0026h - Extended boot record sig brSerialNum DD 404418EAH ; 0027h - Volume serial number (random) brLabel DB 'Joels disk ' ; 002Bh - Volume label (11 chars) brFSID DB 'FAT12 ' ; 0036h - File System ID (8 chars) ;------------------------------------------------------------------------ ; -------------------------------------------- ; Boot program code begins here ; -------------------------------------------- ; boot code begins at 0x003E begin: mov ah, 0x0e ; Function to print a character to the screen mov al, 'H' ; Which character to print mov bl, 7 ; color/style to use for the character int 0x10 ; print the character hang: jmp hang ; just loop forever. ;--------------------------------------------- size equ $ - entry %if size+2 > 512 %error "code is too large for boot sector" %endif times (512 - size - 2) db 0 db 0x55, 0xAA ;2 byte boot signature I save it in h.asm and then convert to bin file using nasm assembler by command nasm c:\h.asm -fbin -o c:\h.bin then i write it to my pendrive using debug by using the following commands debug c:\h.bin -l 0 -n f:\h.bin -w 0 Now everything works uptill now. When i reboot my pc making pen drive as priority boot device. Then i get the error Error reading disk Press any key to restart Then i get message- There is no boot data in your device. Where the things are going wrong. Please help. |
Re: Help needed to Write fist hello world operating system in pen drive.
Firstly I'd like to Organize the code by using code tags and make it more readable..
Code: asm
And I have started Learning OS Boot Kernel and HERE is a very good code resource.. |
| All times are GMT +5.5. The time now is 13:04. |