943,999 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Unsolved
  • Views: 13386
  • Assembly RSS
Jan 2nd, 2006
0

Simple Operating System

Expand Post »
since im new here and this is my first post........

i started programming as a freshman (im now a sophmore) with VB, and have since, i and my teachers feel, have mastered that, tought myself C and am pretty accomplished in that language. I am working on the object oriented part of C. I am looking to create an operating system, have done some reasearch and found most say to use Assembely or a mix of assembely and C/C++. I have gone through a few assembely tutorials, and am completely ready and willing to spend a few years on this project if necessary.

I have at my disposal a development envoriment consisting of a development machine and a test machine, and a way to transfer files between the two, but they are not directly linked.

now that you have a slight background and know what i am capable of doing/learning here is my question.

I would like to create a simple operating system for the x86 platform that will boot up the machine, check to see if a cd is in the cd-rom drive, if so, execute the code (mostlikely in C) from the CD, if not, execute some default code (again, mostlikely C) that will bring up a screen which i can code myself.

wow, there really is no question in there......i guess what i want is to know is if there is an os out there that does this, or something close to this that i could modify. if not then how should i go about starting with this, and any help is apprecieated

lol, hope i came across as clear
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
amrani.ah is offline Offline
2 posts
since Jan 2006
Jan 12th, 2006
0

Re: Simple Operating System

Quote originally posted by amrani.ah ...
since im new here and this is my first post........

i started programming as a freshman (im now a sophmore) with VB, and have since, i and my teachers feel, have mastered that, tought myself C and am pretty accomplished in that language. I am working on the object oriented part of C. I am looking to create an operating system, have done some reasearch and found most say to use Assembely or a mix of assembely and C/C++. I have gone through a few assembely tutorials, and am completely ready and willing to spend a few years on this project if necessary.

I have at my disposal a development envoriment consisting of a development machine and a test machine, and a way to transfer files between the two, but they are not directly linked.

now that you have a slight background and know what i am capable of doing/learning here is my question.

I would like to create a simple operating system for the x86 platform that will boot up the machine, check to see if a cd is in the cd-rom drive, if so, execute the code (mostlikely in C) from the CD, if not, execute some default code (again, mostlikely C) that will bring up a screen which i can code myself.

wow, there really is no question in there......i guess what i want is to know is if there is an os out there that does this, or something close to this that i could modify. if not then how should i go about starting with this, and any help is apprecieated

lol, hope i came across as clear
hmm looks like a LOT of code for cd-rom access i think,
BUT a floppy disk method is VERY easy, for just one, or two seperate
floppy disk drives, i can send you code for a boot loader for fdd if you want?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mikemark is offline Offline
5 posts
since Jul 2005
Jan 12th, 2006
0

Re: Simple Operating System

Quote originally posted by mikemark ...
hmm looks like a LOT of code for cd-rom access i think,
BUT a floppy disk method is VERY easy, for just one, or two seperate
floppy disk drives, i can send you code for a boot loader for fdd if you want?
Yea, that would be great. E-mail is amrani.ah@gmail.com. thx
Reputation Points: 10
Solved Threads: 0
Newbie Poster
amrani.ah is offline Offline
2 posts
since Jan 2006
Oct 22nd, 2009
0
Re: Simple Operating System
Could I get a copy of the boot loader too? My email is jth_92@yahoo.com.

Thanks.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jth92 is offline Offline
1 posts
since Oct 2009
Oct 22nd, 2009
0

sorry to dissappoint

Its been ages since I did assembler, I had a simple notepad with save on same disk (no files, just a random permemenant spot of data), a bitmap file loader&display, serial debug terminal, robotics control (via parallel port), ect ect

Before i ramble on about INT13 you have to understand what disk(0) means and what wiping out your bootsector does, means, and how to backup/restore it without loosing ALL the files on your hdd!!!!!
i reccomend testing this on a computer with the hdd disconnected COMPLETELY. (so if it attempts to wipe the hdd, it will only give you an error?) Be warned.

That was WAY back a while. There was a fire that took my hard drive AND my ****ing backup! ughh! It wasnt terribly difficult, first you need to practise copying from hard drive to memory (use BIOS interupt 13h to copy your instructions from disk to memory) then move instruction execution pointer to the start of that address, DONT FORGET REGISTERS! lol

once your there you can add program objects and a command interpreter (hint, model it on a "notepad" first, then add the actual interaction) but as always remember to save and restore registers (and instruction execution pointer?) after every program /begenning of interupt, and yes you CAN write your own interupts, but i have no clue how (DOS has a few)

here is an unfinished (and untested) example i just pulled from (g)oogle real quick, it'll work because i recognise it's code, but you'll probably have to know basic assembler and registers ect...

mov ah, 2 ; function 2, read sectors
mov al, 1 ; read 1 sector
mov ch, 0 ; track 0
mov cl, 0 ; sector 0
mov dh, 0 ; head 0
mov dl, 0 ; drive 0 (A (0=A, 80h = driv 0, 81h = drive 1)
mov bx, offset buffer ; where to put the data (ES:BX)
int 13h

then you just need to execute the data in the buffer!

NOTE ABOUT BOOT DISKS:
im not sure about hdds, but with floppys and probably hdds too, you need to make sure a specific two bytes on the disk are set to a specific value in order for the BIOS to even ATTEMPT to copy&load the bootsector. very important.

hope that helps! and good luck with your projects!

NOTE: example is taken from
http://www.programmersheaven.com/mb/...3h-service-02/
i make no claim to rights of blah blah blah .....
want me to take down?, PM me
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mikemark is offline Offline
5 posts
since Jul 2005
Oct 23rd, 2009
0
Re: Simple Operating System
Click to Expand / Collapse  Quote originally posted by amrani.ah ...

I would like to create a simple operating system for the x86 platform that will boot up the machine, check to see if a cd is in the cd-rom drive, if so, execute the code (mostlikely in C) from the CD, if not, execute some default code (again, mostlikely C) that will bring up a screen which i can code myself.
An excellent starting point is this link , Just download the OSD.ZIP file and start reading:
http://geezer.osdevbrasil.net/osd/code/

Tony
Reputation Points: 10
Solved Threads: 1
Newbie Poster
AMarchini is offline Offline
4 posts
since Sep 2009
Oct 24th, 2009
0
Re: Simple Operating System
Func AH=2 INT 13h Disk Services:
CH=Low eight bits of cylinder number
CL=Sector number should start at 1
bits 6-7 represent two high bits of cylinder number (hard disk only).
So the MBR would be at Cylinder/Track 0 head 0 Sector 1

"NOTE ABOUT BOOT DISKS:
im not sure about hdds, but with floppys and probably hdds too, you need to make sure a specific two bytes on the disk are set to a specific value in order for the BIOS to even ATTEMPT to copy&load the bootsector. very important."
This is true for floppy disks too.
These two bytes are at offsets 510 - 511 (offsets relative to 0)
and is a WORD which contains AA55 or a byte at a time 55-AA
these are the last two bytes of the 512 byte boot sector,
your bootloader must fit within 512-2 bytes or else it will have to
load the rest from another part of the drive itself.

Even in the documentation I have the track/cylinder seem to have
the same meaning - but I read in MS-DOS encyclopedia that
cylinder actually refers to the number of like numbered sectors
on the drive.

Learning how operating systems work or are implemented for
a particular architecture can be qwite educational,
x86:
A 16-bit operating system is pretty straight forward,
besides device drivers which require proprietary information
lest the primitive services of the BIOS are used to create the drivers,
and managing a file system on a harddisk,
it uses the same parts of the architecture for implementing
services for programs and managing them as do the
applications which it serves.
32-bit architecture is not as straight forward, there are
parts of it reserved for system programs,
and several system data structures used by the CPU.
It is more complicated.
No reason to be discouraged at all though.

Older DOS systems I believe had a bootloader on the MBR
which contained a partition table with information on
partitions on the drive and which was bootable.
The MBR also contained the BIOS Parameter Block.
The first sector of the bootable partition was loaded into
memory and executed.

Good day...
[[AxxXx3BBbLbLLLaAzXxZiO]]
Last edited by NotNull; Oct 24th, 2009 at 10:08 pm.
Reputation Points: 36
Solved Threads: 19
Junior Poster
NotNull is offline Offline
198 posts
since Oct 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Assembly Forum Timeline: Counting 1's in 16 bit word
Next Thread in Assembly Forum Timeline: Pep





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC