Bona Fide OS Development
http://forums.osdever.net/

Writing an OS in Assembly- Questions
http://forums.osdever.net/viewtopic.php?f=5&t=244
Page 1 of 2

Author:  Wendell890 [ Tue Mar 30, 2010 6:22 pm ]
Post subject:  Writing an OS in Assembly- Questions

How would I make almost all of my OS through ASM?
Is it possible to write simple runnable programs through ASM that I can run in my Kernel?
Thanks.

Author:  Terry A. Davis [ Tue Mar 30, 2010 6:35 pm ]
Post subject:  Re: Writing an OS in Assembly- Questions

It's silly to do all assembly unless

1) You wrote your own assembler and have not yet written a compiler.
2) You think it's fun.

Assembly is really a pain to maintain. Small changes often mean redoing all registers or rewriting functions. It's tedious on big things.

On modern processors, it doesn't offer much of a speed improvement. Modern CPU's run two tiny instructions at the same speed as one big one. Whether things are cached, too, is often more important than the code.

You might impress people who don't know better. That's a possible reason. Most programmers see it as macho, or something, or assume it will be faster.

Author:  Wendell890 [ Tue Mar 30, 2010 7:03 pm ]
Post subject:  Re: Writing an OS in Assembly- Questions

I find it fun and exciting when I see something that I set up working, and with assembly, it's easier for me.
I've had to use languages like Scratch (MIT) to get fast results, however for me I understand (partially) what's going on within the assembly code, which is why I think I would do better writing the majority of my OS with Assembly.

Author:  Terry A. Davis [ Tue Mar 30, 2010 7:52 pm ]
Post subject:  Re: Writing an OS in Assembly- Questions

Yeah, years back, you used to hear of asm programmers who, ironically, found high level programming languages too complex. That used to make me crack-up laughing because you can see how it's true, sometimes. It was more true with older, simple processors. Today's processors are much more complicated, at least x86.

I guess your point relates more to operating systems. When you must do unusual low level things, like for an operating system, high level languages can be lots of trouble because you can't tell what your compiler is doing with registers and stuff. They're not designed well for mixing with ASM.

Author:  Wendell890 [ Tue Mar 30, 2010 7:57 pm ]
Post subject:  Re: Writing an OS in Assembly- Questions

Yeah, that's the same with me. I used the OSdev wiki Kernel script as my primary starting point, and now that I've got it working, I'm confused on where I should go next. This kernel script used no bootloader, so I'm thinking I should write one of those, or do something else and come back to the bootloader. What do you think?

Author:  Terry A. Davis [ Tue Mar 30, 2010 8:20 pm ]
Post subject:  Re: Writing an OS in Assembly- Questions

Boot loader is a good plan. You'll have to enter the realm of 16-bit asm programming. It's annoying -- stupid segmentation. Sucks for new programmers having to bother to learn it because it's only relevant for boot loaders, for the most part. We grew-up with it when it was normal.

Anyway, one big challenge for boot loaders is getting your code written to the first sector from an operating system which is probably trying to keep you from doing that. I guess if you're using VMWare or whatever, you just need an image and don't have to actually write the to real boot loader.

Umm... you might want to do ATA support first, to get the hang of it.

I began with a floppy and moved to a CD-ROM. I'm not sure what to recommend.

You can look at LoseThos, my operating system, http://www.losethos.com.

You probably want to do it your self, I guess? I suggest you search for ATA or ATAPI (CD-ROM).

http://www.t13.org/Documents/UploadedDocuments/docs2007/D1532v1r4b-AT_Attachment_with_Packet_Interface_-_7_Volume_1.pdf
http://www-users.itlabs.umn.edu/classes/Spring-2009/inet4031/lecture/What%20are%20ATA%20and%20ATAPI.pdf

I have some good documents I pulled from the web long ago, but don't know if I can redistribute. Damn standards organizations often charge money, the bastards.

Maybe, you're going to do a floppy image and run it in VMWare or Bochs or whatever? The boot loader usually uses BIOS int 13, #42

http://lrs.uni-passau.de/support/doc/interrupt-57/RB-0670.HTM

Later, you'll prolly want to do the ATA/ATAPI stuff.

Author:  Wendell890 [ Wed Mar 31, 2010 6:31 am ]
Post subject:  Re: Writing an OS in Assembly- Questions

I'm running Mac OSX on an Intel Mac, so I have to do everything within terminal. Luckily, the main problem I was having was that the .imgs that I generated weren't readable by the virtual machine. So I downloaded a sample disk, booted it up to make sure it worked, then cleared it and put my kernel on. Using this command " dd if=FILE.bin of=/dev/DISK bs=512 count=1" I can choose the sector of the "floppy" that I use. And I can have as many of these "floppies" as I want.
(The video on the LoseThos is quite choppy. I can understand what you're saying, but I can barely see what's going on. Nice GUI, though.)

Author:  Terry A. Davis [ Wed Mar 31, 2010 6:48 am ]
Post subject:  Re: Writing an OS in Assembly- Questions

That was clever. Good job. You don't need my help. Just use google :)

Author:  Wendell890 [ Wed Mar 31, 2010 3:10 pm ]
Post subject:  Re: Writing an OS in Assembly- Questions

Actually, I think it would be better for me to get some help from someone who's made their own OS before.
Google gives me bits and pieces and I don't usually find what I'm looking for.

Author:  Wendell890 [ Thu Apr 01, 2010 6:09 am ]
Post subject:  Re: Writing an OS in Assembly- Questions

Alright, so I tried to add some more commands to my kernel, and I had to size up the thing at the bottom of my kernel to 552 bytes to make it compilable. However, this presented me with an error: I couldn't copy it onto a disk with the 512 sector size. So, I am at a stand-still in my progress. When I try to run it, it does fine until I try to press RETURN. This made the OS freeze, and I'm assuming it's the 552 size. So how would I chop up my kernel and make it all included? (I know this is an extremely noobish question, but I have yet to find a good tutorial that can explain this idea extremely well.)

Sorry for the double post.

Page 1 of 2 All times are UTC - 6 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/