News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

MASM OS

Started by brodeur235, May 09, 2009, 09:56:54 PM

Previous topic - Next topic

brodeur235

I know basic masm syntax and concepts. The reason I've learned it is to write my own operating system. For now all I want is something very minimalistic, but I have no idea where to begin. Do I have to create an .ISO image. If so, what do I put it in and where? How do I boot from it? All I really want the os to be capable of doing for now is booting up and displaying a message such as "hello world." All help is appreciated,

Broduer235

Vortex

Hi brodeur235,

Welcome to the forum.

Creating operating systems is an advanced task. You should start with studying Iczelion's Win32asm tutorial set

dedndave

if you want to write an OS eventually, i also suggest you become very familiar with the BIOS code to start off
having done that, you will know what process the machine goes through at start-up
also, DOS is a simple OS - take a look at how it works - it is much simpler than trying to figure out how a win OS works

EDIT:
in fact, you can write a 16-bit program and name it command.com
use io.sys and msdos.sys and the boot sector from DOS
that will do the "diplay a message at start-up" that you wanted

Farabi

You will need to create a program that able to boot before you write it to a CD. THat program should be writen to the first track. I guess FASM board have all the info.

I need to tell you this, re-read the MASM license, it are not allowed you to write a program for another OS except Windows.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

redskull

If you PC doesn't have a floppy, I like the flexibility of a USB flash drive (if your computer supports booting from one) so that you don't burn through CD's every time.  Then, like it was said, you just have to put executable code into the first byte of the first sector, and 55 AA in bytes 510 and 511, respectively (so the BIOS knows its a valid image).  I like the HxD Hex editor to do so (http://mh-nexus.de/en/hxd/); you can just copy and paste the hex codes from a debuggers memory dump.

-r
Strange women, lying in ponds, distributing swords, is no basis for a system of government

Vortex

brodeur235,

Virtual PC and Vmware are other suitable environments to test operating systems.

Mark Jones

Redskull, you would probably be the one for this job. Someone needs to make a simple "beginner's" package which will write a boot sector + loader to a floppy. Then we could just say "here, take a look at this" to these kinds of questions. Either one of two things will happen: one, the learner will experiment with it, learn from it, and make the next greatest OS. Or two, become overwhelmed at the innocuous complexity of it all and go back to visual basic. :bg
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

redskull

Hey, I'm still scared by innocuous complexity!  There's no loader, but there is a simple, bootable "Hello World" with a longwinded explanation of how it came to be.  Hopefully it helps someone.

-r

[attachment deleted by admin]
Strange women, lying in ponds, distributing swords, is no basis for a system of government

brodeur235

Redskull, thank you. That picked up at exactly how much I knew, e.g. general purpose and function of a bootable OS, and filled me in on the much needed technicalities of it. I especially liked that you used a usb to boot. Also, you left me with some great ideas to play around and work with such as interrupt 10 text color, etc. Excellent help. Anyways, I do have a couple questions, mostly about debug.exe. When I use it am I actually altering registers and memory while the current OS (windows now) is running? This doesn't seem possible, yet the memory addresses accessed by debug contained hardware specific info, which is to the contrary. Very confused there. A few minutes ago I had a couple more questions, but after carefully reviewing your explanation, I just found the answer to both... So, sorry if you already answered that last question somewhere in the rtf. All help appreciated,

Brodeur235

brodeur235

I have 1 fairly problematic dilemma.... My firmware won't boot from it. My regular boot menu, which detects bootable partitions (hd, cd drive, usb drive) does not detect the bootable flash. However, rEFIt does. (If you don't already know, rEFIt is what most mac users use as a boot menu if more than 2 HD partitions are present, otherwise all partitions after the first osx partition are seen as windows. with rEFIt you can see linux, windows, dos, solaris, etc.) As I said before, rEFIt does see my bootable OS. When I try to boot from the USB in rEFIt, i get this error message:


I'll let you interpret this to the best of your abilities because I can't seem to make much more of it than I'm ******, and that's not what I want to hear. It says:

STARTING LEGACY LOADER
USING LOAD OPTION 'USB'
ERROR: NOT FOUND RETURNED FROM LEGACY LOADER
THE FIRMWARE REFUSED TO BOOT FROM THE SELECTED VOLUME. NOTE THAT EXTERNAL
HARD DRIVES ARE NOT WELL SUPPORTED BY APPLE'S FIRMWARE FOR LEGACY OS BOOTING.
* HIT ANY KEY TO CONTINUE *

Hitting any key takes me back to the boot menu.

BlackVortex

Just use Virtualbox or another VM product. I can't believe someone actually would bootload this proof of concept "OS" in a real machine, messing with bootloaders etc.

redskull

It would appear as though your BIOS isn't capable of booting from a USB device; It has to support 'legacy mode', which is more-or-less a way that the BIOS maps the USB device to appear as a hard drive so it can work through the old school INT 13.  As far as using it with rEFIt goes, I've never used it so I can't say for certain, but there's a strong possibility that it depends on the functions the BIOS provides (e.g. no BIOS support, no bootloader support).  Also, perhaps I should have clarified, but I have absolutely no idea if the Intel Macs boot up the same way as the Intel PC's.  You options are to either A) get a BIOS update and hope it supports USB, B) use a different computer that does, C) do everything on a floppy disk instead, or D) use a virtual machine program (though its often less fullfilling to see something 'emulated' instead of for real)

-r

***EDIT***

a quick search turned up this: http://refit.sourceforge.net/doc/c4s1_notfound.html
Strange women, lying in ponds, distributing swords, is no basis for a system of government

Mark Jones

Again just a pedantic note, we are assuming JWASM or POASM is being used, because the MASM license prohibits creating new OS with it. (JWASM has identical syntax to MASM, so just call jwasm.exe instead of ml.exe.)

I've also seen this USB behavior (my box won't boot from a USB stick natively either, even though it properly recognizes them in the BIOS.) For fun, tried to install Windows to one, and it said that it was not a proper bootable device. I think Redskull's hit the nail on the head however, that loader should do the trick.

Another added benefit of VMware is that you don't need to physically reboot the computer each time a test is made; I think it would be much nicer to only wait 15 seconds instead of 2-5 minutes for the test and reboot, plus inserting and removing the flash stick...
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

brodeur235

I am very sorry to be asking so many - probably annoying - questions but I'm literally working at this 24/7... I stayed up all night and still haven't found a solution: I want to boot the os in virtualbox. Virtualbox can't boot from usb's either so that idea's out. My thinking: make an iso. However, all I have is a 512 byte binary(.bin) file that I want loaded as the boatloader @ 0:7C. How do I go from this .bin to an iso. Apparently cds boot differently than regular HD partitions and USB drives. As far as I have read/found you don't write your bootloader code to the first sector of a cd to make it bootable. I have found a few .img to .iso tuts/walkthroughs, but I don't even have an .img (pretty sure that's the extension for a bootable floppy image..) Again, how can I translate my 512 byte bin into ANY bootable device,image,etc to be booted up in virtualbox. (I'm not interested in just iso's, thats just one option I found while researching and lord knows I'm not the best at researching). Help appreciated,

Brodeur235

dedndave

well - you could use almost any cd boot image for that
the one for windows xp install cd, for example
now - if you want to see what the boot image does, it is only 2 kb and easy to disassemble or modify

when you create the cd, you must go into the cd burner program and tell it you want to make a bootable cd
it is 2 kb - you have to load it at segment 0 and tell the cd burner it is 2 kb (4 sectors)
i use CDBurnerXP
http://www.cdburnerxp.se/

EDIT
here is another site you might find helpful...
http://www.bootdisk.com/

you can create your own bootable image by making it similar to a
.COM program, except it is ORG'ed at 7C00h instead of 100h