Hi guys. so i wanna code my own Simple Dos-like OS that boots to a prompt with the simple command of "Hello" which should load a message that says "Hello, World!". Would someone be generous enough to give me some source code that just boots and has the command "Hello". I can do everything else from there. all i need is basically the bootloader and the prompt. Thanks!

Recommended Answers

All 9 Replies

Oh and i want it to boot with a CD not a floppy cause my floppy drives busted

You can find extensive information, including sample boot loaders, at OSDev.org. I would recommend being careful about posting to the fora there, however, as they expect you to carry your own weight, and a blanket request such as this one is likely to get negative reactions.

That having been said, I would recommend using GRUB as your bootloader rather than trying to roll your own. GRUB does many of the basic startup tasks for you, and let's you start from a fairly well-developed point.

As for a command-line action, you're on your own.

commented: He seems like the only person that helps people with asembly, he gets there fast and helps you find your answer! +1

You can find extensive information, including sample boot loaders, at OSDev.org. I would recommend being careful about posting to the fora there, however, as they expect you to carry your own weight, and a blanket request such as this one is likely to get negative reactions.

That having been said, I would recommend using GRUB as your bootloader rather than trying to roll your own. GRUB does many of the basic startup tasks for you, and let's you start from a fairly well-developed point.

As for a command-line action, you're on your own.

I totally forgot about grub haha. Thanks for the info

You should check out MikeOS. It's completely written in assembly, and I believe it can be booted from a floppy or a cd.
http://mikeos.berlios.de/

I would also recommend using an emulator (e.g., Bochs) or virtualizer (e.g., VirtualBox, QEMU, VirtualPC) rather than running off of live hardware, at least while testing and debugging. If nothing else, it would save you the constant work of rebooting the system as you test it, as you will be able to run the OS inside of your development machine.

I have bochs installed on my computer, and i have small boot disk OS from floppy.
Could someone help me how to boot floppy on bochs? I read the instructions from
bochs wiki but i'm still confuse.

; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««« *

    .486
    .model flat, stdcall
    option casemap :none   ; case sensitive

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

    include \masm32\include\windows.inc
    include \masm32\include\kernel32.inc
    include \masm32\include\msvcrt.inc

	includelib \masm32\lib\msvcrt.lib
    includelib \masm32\lib\kernel32.lib
	
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

	.data
		Str1		db	"Hello, World",0
		Str2		db	" ",0
		Str3		db    "Unkown Command ",0
		
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
	
    .code
	
ClearCIn proc

	PUSH STD_INPUT_HANDLE
	CALL GetStdHandle
	PUSH EAX
	CALL FlushConsoleInputBuffer
	RET

ClearCIn Endp	

main:

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
	
	PUSH OFFSET Str2
	CALL crt_scanf ;function Scanf from C, scan the written string and put into de Str2, this is located @\masm32\lib\msvcrt.lib
	ADD ESP,8	
	CMP Str2, "Hello"
	JE PrintHelloWorld
	PUSH OFFSET Str3
	CALL crt_printf
	ADD ESP, 4
	JMP main
	
	PrintHelloWorld :
	PUSH OFFSET Str1
	CALL crt_printf		
	ADD ESP,4			
	
         CALL ClearCIn
	;Clean the screen
	PUSH OFFSET Str8
	CALL crt_system
	ADD ESP,4
	
          ;;Start all over again
	JMP main
	;this ExitProcess is never gonna hapen,cause i always start all over again,but i put it anyway
		PUSH 0
	CALL ExitProcess

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

end main

I have bochs installed on my computer, and i have small boot disk OS from floppy.
Could someone help me how to boot floppy on bochs? I read the instructions from
bochs wiki but i'm still confuse.

The main thing you need to do is create a disk image. Fortunately, Bochs comes with a tool, bximage, which makes it easy to create a blank disk image, or (if you already have a disk) copy a disk image to a file.

You can also use a physical disk with Bochs, if you prefer, rather than a disk image file.

To make a bootable 1.44MB disk image, create a binary file
exactly 1474560. The first 512 bytes of this image at the
very beginning will be the Boot Record.

Stack may not be initialized upon entry. If so set up
your own stack.

mov ax, cs
mov ss, ax ; will disable interrupts until end of next instruction.
mov sp, my_stack
ORG 7C00H ; The ROM will place your code at 07C00H
MyFirstBootLoader:
MOV SI, MSG  ; Load SI with offset of Message
CLD ; Clear DF bit for string operation
DisplayMessage:
LODSB ; Load byte of string into AL
CMP AL, 0
JZ BootOver ; Exit if byte was zero
MOV AH, 0EH ; Function 0EH Write in TTY Mode
MOV BH, 0 ; Display Page Zero (Should be current)
INT 10H ; Video Services Interrupt (BIOS)
JMP DisplayMessage
BootOver:
JMP BootOver ; Infinite Loop
MSG DB 'Hello World', 0DH, 0AH, 0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.