News:

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

Is it possible to use MASM32 to write my own OS?

Started by lonewolff, July 19, 2009, 09:56:06 AM

Previous topic - Next topic

lonewolff

Never being content with the size of current applications, let alone a whole OS. I have decided to try and write my own operating system.

So far so good, I have started by modifying a boot sector on a virtual machine and can boot straight into my new operating system that boots up and says "Hello World" and then goes into an infinite jump. Sounds un-interesting, I am sure. But I think it is awesome that I have gone this far :)

So, far I have been programming my ~20 byte operating system tediously by hand in 'debug.exe'.

Is it possible to use MASM32 to compile my OS into a bin file or something rather than using debug? The reason for a simple sounding question is that all of my MASM32 programming has been Windows API based thus far. I would prefer to use 32 bit instructions rather than 16 bit if possible, but I am happy to start out either way.


Thanks in advance.

MichaelW

One method would be to use full segment definitions, assemble with ML /c, and link with the 16-bit linker and /tiny.

The attachment contains code for a minimal boot sector, intended to serve as the boot sector of a diskette. I think the components are functional as far as they go. Note that the diskette must start out with a valid format, as otherwise DEBUG will not be able to write to it, and that after this particular boot sector is written to the diskette it will no longer have a valid format. Somewhere I have code for a boot sector that will preserve the valid format, so the file system on the diskette will remain functional.


[attachment deleted by admin]
eschew obfuscation

lonewolff

Awesome!

That is exactly what I was looking for.  :U

I should be ok with the preservation of the essential parts in the boot sector. Although I may not need them anyway as I am looking at creating everything from scratch in my OS. Yes, I know why re-invent the wheel. But what better way to learn, hey?  ::)

dedndave

the licensing is different for different versions of MASM
you may want to use 6.14 or 6.15 instead of a newer version

FORTRANS

Hi,

   A similar thread with some good replies.

Please help a total newbie.
http://www.masm32.com/board/index.php?topic=11282.0

Steve

redskull

Another thread here: http://www.masm32.com/board/index.php?topic=11397.0

Just as a note, it's against the license to use MASM to write an O/S

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

lonewolff

Quote from: redskull on July 19, 2009, 02:43:02 PM
Just as a note, it's against the license to use MASM to write an O/S
Bummer, I didn't think of that.   :(

Is that regardless of whether it is for 'non-commercial' purposes, ie. a personal project?

dedndave

if you like the masm syntax, GoAsm and some of the other assemblers are quite compatible
no license regarding writing an OS
writing an OS is a major undertaking
it requires in depth knowledge of all processors that are to be supported
it also requires a certain degree of hardware knowledge
i would kind of like to write a debugger
at this point, it is a bit over my head - lol
i am learning, though
the point is, don't jump into your first fight and take on the biggest guy with the green teeth

disintx

Quote from: lonewolff on July 19, 2009, 09:46:09 PM
Quote from: redskull on July 19, 2009, 02:43:02 PM
Just as a note, it's against the license to use MASM to write an O/S
Bummer, I didn't think of that.   :(

Is that regardless of whether it is for 'non-commercial' purposes, ie. a personal project?

Regardless, yes. MASM cannot be written to write non-Windows programs.

From the license:
Quote
What you CANNOT do with the MASM32 Project.
1. The MASM32 Project is not an item of trade or commerce. It cannot be either purchased or sold.
2. The MASM32 Project cannot be re-licenced or made subordinate to any other form of licence.
3. None of its components or source code are redistributable.
4. You cannot use the MASM32 Project to write software for Non-Microsoft Operating Systems.
5. You cannot use the MASM32 Project to write any form of illegal software.
6. The project does not authorise the use of the Microsoft Trademark in your software or claims that your software is certified by Microsoft.

hutch--

lonewolff,

The licence is no big deal with a bootable floppy as this is not an OS by any commercial or objective standard. You certainly cannot use MASM for Linux, ReactOS or the MAC OS as they ARE competing operating systems but a floopy is a floppy and Microsoft have had the tools and toys for years to make and/or write bootable floppies.

If you do develop an OS up to the Linux or MAC OS size and standard, you will not be doing it in MASM, you will need a suite of C compilers, a development team and some assembler language system programmers to screw together the important high speed stuff but writing a bootable floppy as a hobby OS you have no problems at all.

Long long ago I remember using MASM to write modified floppy boot sectors with very noisy warnings if the machine was booted from the floppy, it was aimed at teaching people NOT to leave unknown floppies in their bootable floppy drives.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

lol Hutch
or a boot-floppy that displays a screen like this....

Format complete on hard disk C:
Press any key to continue...

then goes into an endless loop - lol

Neo

The painful part is linking, because the MASM linker doesn't support giving fixed addresses to segments, and doesn't support having 16-bit and 32-bit code together, let alone 16-bit, 32-bit, and 64-bit code together.  There's JLOC, but it only supports 16-bit and 32-bit.  That's why I've worked like crazy to get support for 16-bit, 32-bit, and 64-bit code all linked together, and a simple interface for choosing where you want the segments in memory and the file, in Inventor IDE in time to build PwnOS for my honours project (report due mid-August).  :U

I haven't released the version with support for it yet, 'cause there are a few kinks to be worked out; mostly to do with updating the parsing and error detection after changing segment properties.  There isn't much left to do on it; I just need to get my honours project done first, so if you can wait until late August, it could help a lot.  After doing OS development with MASM and JLOC before, I couldn't imagine going back.  The turnaround time for a short change, build, copy, test is like 20-30 seconds instead of a minute or two, so I've made more progress on PwnOS in the past month than I ever made on it before.  :bg

hutch--

Dave,

If you really wanted to scare someone years ago you ran a TYPE style dos interrupt on IO.SYS that pelted a pile of crap on the screen complete with beeps and squarks then when it had run to the end you displayed "Non system disk, press any key to continue ..." then dumped it into a closed loop.

They learnt real quick not to leave unknown floppies in a floppy drive.  :bg
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

lonewolff

Thanks for the tips guys!  :bg

Does anyone know where you can get a current (or relatively current) instruction set that actually has what the opcodes are and their hex values. I can find lists of opcodes all over the place but I can never find the actual hex codes for them.  ::)

hutch--

Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php