0

i know MIPS asm and i'm studying a little bit of x86 asm (i use masm), recently i'v read about mikeos and in particular about this: http://mikeos.sourceforge.net/write-your-own-os.html And i have some questions:

1) Is there any IDE on windows that can help me compile and execute this low level code? How can i debug it if this ide does not exist?

2) With these tutorials i'm in the bootloader section, what if i need to access to a file? eg. i want to make a simple text editor in my bootloader, how can i access to a hard-disk located file?

3) this is the bootloader right? let's suppose that i implement some functions here and i create a nice bootloader, what is the next step?

Thanks in advance, also, where can i find some other material?

Raydar
  • 5
  • 2
  • 2
    Learn Linux. Use it (and perhaps study it somehow, e.g. [ALP](http://www.makelinux.net/alp/)...) since it is developer friendly. Don't spend months on your own bootloader, use an existing one (e.g. [GRUB](https://www.gnu.org/software/grub/)). See http://osdev.org/ & http://pages.cs.wisc.edu/~remzi/OSTEP/ – Basile Starynkevitch Aug 18 '18 at 16:51
  • Thanks :) i'll take a look – Raydar Aug 18 '18 at 16:54
  • 4
    Some advice: 1) don't give up, small projects are useful to learn and present oneself. 2) Use nasm, masm is mainly for Windows. 3) You don't need an IDE, there is nothing to aid you with (only label names) 4) Bootloaders deal with hardware, you build SW concepts on top of it (e.g. ask how to access the HDD and easy that out for any application - et voilà, you just reinvented the file) 5) Booloaders run in an "hostile" environment that make them hard to develop, so they make a custom "comfortable" environment, load a custom format file, easier to develop, into it (the kernel) and run it. – Margaret Bloom Aug 18 '18 at 17:15
  • BTW, why do you want to make your own OS? Why not build something above or for some *existing* OS? – Basile Starynkevitch Aug 18 '18 at 18:37
  • @BasileStarynkevitch because i'm fascinated from everything that comes from the low-level world. – Raydar Aug 18 '18 at 20:56
  • Do you already have some `git` repository for your OS project? Where? – Basile Starynkevitch Aug 18 '18 at 21:11
  • nope @BasileStarynkevitch, i wrote this question bcause i was lost XD – Raydar Aug 18 '18 at 21:15
  • Then, make first some `git` repository (perhaps on [github](http://github.com/) or elsewhere). Write there a few notes about your design. Then code just enough code to show some `hello` on the screen. Once you did that, edit your question to add that `git` project. – Basile Starynkevitch Aug 18 '18 at 21:16
  • Feel free to send me an email to `basile@starynkevitch.net` mentioning the URL of your question – Basile Starynkevitch Aug 20 '18 at 07:11

1 Answers1

2

Learn Linux. Use it (and perhaps study it somehow, e.g. ALP...) since it is developer friendly. Don't spend months on your own bootloader, use an existing one (e.g. GRUB).

See OSDEV wiki (IMHO it is better https://stackoverflow.com/a/51944435/841108than your MikeOS link) & read absolutely Operating Systems: Three Easy Pieces. Take several weeks to read and learn stuff (before even coding).

Is there any IDE on windows that can help me compile and execute this low level code?

You should prefer using Linux, and you certainly do not need an IDE, but a good source code editor (you should not use an IDE, because it hides you details that you need to understand; you need to use commands and understand what each command is doing). My preference is emacs but you might use other editors (like vim, gedit, etc...).

You'll use a C compiler (somehow as cross-compiler; you may want to choose calling conventions similar to existing ABIs, so study them). My recommendation is GCC (and there is also Clang). You need to understand in details how to invoke gcc. You certainly want all warnings (so -Wall -Wextra). You might want debug information in DWARF format with -g, and some optimizations flags (e.g. -O1 or -O2). You'll want to use some build automation tool (e.g. ninja, make, ...) and some version control system (choose git and publish your code as free software, on github or something else; do that quickly to be able to get feedback).

You'll use a linker (you could read Levine's Linkers and Loaders book). So binutils and its ld (of course you'll have some assembler code). You'll need to understand linker scripts and probably details about ELF format.

How can i debug it if this ide does not exist?

Painfully. Perhaps you'll use some emulator or virtual machine, and do remote debugging with gdb (it is not simple; so you won't have that luxury at first). Practically, you first want to code some screen output (perhaps your own console_printf, but without using <stdio.h>) and use that.

what if i need to access to a file?

You really are confused (without writing or borrowing a lot of code, you cannot access any files). An OS (even your toy OS) is implementing file systems, and don't have any without that. So your OS will (later) provide some file abstraction (to whatever software it is able to run). You won't access to any files at first (but GRUB can, but only at boot loading), and even reading blocks from the raw disk (or some partition) is difficult (SATA, DMA, interrupts, etc...). BTW, you could design your OS without files, but with some other ways to have persistence. And if you go for files, you'll need to implement a file system.

Be aware that an OS is complex, because it has to implement everything (including screen display, disk access, keyboard handling, mouse handing, processes and their scheduling, memory management and virtual memory) above the hardware. And a PC hardware is much more complex (USB, SATA, Ethernet, ...) than it was 25 years ago.

what is the next step?

Think about OS design (scheduler & multitasking, persistency, process isolation, system calls). So read a lot. Look into existing projects (Pliant, HURD, NewOS, Haiku, Tunes -inactive but interesting- ...) You won't be able to implement many features, so work progressively. You probably want first to be able to display some text on your screen (study how other existing free software OSes are doing that!). If you take some code from a free software project, be sure to respect its license.

Have fun and be patient. Perhaps working with a good friend might be worthwhile (since even a tiny OS is a huge project for a single person). This answer is related to your motivations.

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547