building an os with basic

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Pasha
Posts: 10
Joined: Fri Dec 19, 2008 10:56 am

building an os with basic

Post by Pasha »

Hello, I am in the process of trying to learn the languages I need to write an operating system. So far All i have gotten was an os that could recieve text in a console like manner, but couldn't do anything with the result, because I didn't know how to access ram. This was in assembler. I do however have a very good knowledge of the Basic programming language(I have programmed in QB45 for the last 6 or 7 years, and have made many text and graphics based programs. My first question is as follows: is it possible to program using basic, and if so how? could I translate basic to c somehow, or is there a way to compile basic to a binary like with c. any help would be appreciated.
Ps. I realize I would still have to do significant amounts of work in assembler to make it work, but I am just wondering if there is a way to get basic integrated in with c and assembler for an operating system.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: building an os with basic

Post by Solar »

Pasha wrote:My first question is as follows: is it possible to program using basic, and if so how?
It is possible for people who read sticky threads before posting to a forum, and are capable of using search functionality to find out if a question - especially a generic one like this - has been asked before. Without being told to do so before.

I would recommend paying special attention to the "Required Knowledge" bit.

Where?

Well, there's a link in the sticky thread you ought to have read first. The one named "FORUM RULES - REQUIRED READING"...
Every good solution is obvious once you've found it.
Pasha
Posts: 10
Joined: Fri Dec 19, 2008 10:56 am

Re: building an os with basic

Post by Pasha »

I did check the search engine first. I typed in basic language and only got things about basic C and basic concepts, and I went through two pages of that kind of stuff before I went to the trouble of starting a new thread. I am sorry, I will look harder.

Ps. I have spent the last 20 minutes or so looking at the search results for "building an operating system with basic", "os programming, basic," and similar searches without finding any remotely similar matches. Pleas follow the forum rules by not starting fights. I agree it is annoying when people don't search first. it causes useless junk on forums, and makes searching for the bit of knowledge one wants to find very difficult. I actually spent a significant amount, several hours, looking on the internet, and trying a few ideas of my own on how to accomplish writing an operating with basic. However, I was unsuccessful. for this reason, and this reason only, I came to OS dev, and tried to see if anyone could help me out. Thanks for the comment.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: building an os with basic

Post by Solar »

OK. After trying it myself, I admit it is a bit difficult to get the search terms right, especially if you don't know what you're looking for exactly. (Then again, not being able to find information on a specific subject can also give you a hint, but that would be pointless pointification.)

So I'll provide you with a couple of links and an opinion.

Languages
Getting Started, and there especially
Required Knowledge (the sticky thread link I was talking about earlier).

The opinion... QBasic isn't a language that gives you a good base for OS development. Neither as a language, nor as previous experience.

Usually, the first few questions of a new user here give a good impression of his experience and mindset.

You seem to be a decent, friendly person - and you can actually express yourself clearly and fluently. Sadly enough, that isn't always the case with newcomers... but the very question you are asking, whether Basic could be translated to C or compiled to binary somehow, points to some lack of experience in the "low-level" area of expertise that is crucial for OS development.

Some on this forum think that the best way to gather the experience necessary for OS development is to just start. I am not one of them. I firmly believe that anyone who is not already an experienced coder when beginning this task, will not find much joy or make many friends on this endeavour, as he is bound to make all those Beginner Mistakes and ask all those beginner questions (and get flamed for them), and spend many fruitless hours trying to figure it out with very little to show for it in the end.

My suggestion: Start learning C, or C++. Not only because most OS work is done in one of these two languages, or because these two are especially suited for this kind of work, but also because knowing just one language doesn't put you in the position of "experienced coder". Write some "normal" applications. Not toy projects either, but some code that really does something. Then, when you've become familiar with compiler toolchains, debugging of binaries, buffer handling and all that stuff, then come back and ask yourself if you really want to do OS development, or if user space apps aren't more rewarding.
Every good solution is obvious once you've found it.
Pasha
Posts: 10
Joined: Fri Dec 19, 2008 10:56 am

Re: building an os with basic

Post by Pasha »

Thank you very much, solar. I have already started on both c and asm, but I thought there might be a possibility of using the old familiar basic, in which I am much more proficient. I agree, it has a lot of deficiencies for os programming, but I just wanted to know if I might be able to use it for certain simple things that just take me forever in either assembler or C. again. Thank very much for your time, and patience with me. You are right, I really don't know much about low level programming, and I really have a lot to learn.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: building an os with basic

Post by AJ »

Hi,

I believe Combuster created a kernel in FreeBasic. IIRC he did this as a test rather than for a "production" kernel (correct me if I'm wrong...). In fact, the wiki contains a FreeBasic Barebones kernel. Just don't expect to find too many tutorials / code samples if you get stuck, though :)

Cheers,
Adam
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: building an os with basic

Post by Troy Martin »

If anything you should be extremely familiar with C-like concepts, such as pointers, integer sizes, etc, inline assembly, and all those wonderful things before you even attempt to write a kernel in BASIC.

I'd assume you need a C backend for a functional FreeBASIC kernel (meaning one that does something relatively useful) anyways..
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
Pasha
Posts: 10
Joined: Fri Dec 19, 2008 10:56 am

Re: building an os with basic

Post by Pasha »

Thanks a lot. I will definitely look into it. and keep you posted. I agree a lot of C code would have to be used before anything really useful could be generated.
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: building an os with basic

Post by Dex »

You can also use macro to make asm more basic like, see this example:
http://forum.osdev.org/viewtopic.php?f= ... 7&start=15
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: building an os with basic

Post by Combuster »

Troy Martin wrote:I'd assume you need a C backend for a functional FreeBASIC kernel (meaning one that does something relatively useful) anyways..
You don't require C at all. However, the available implementation of the BASIC runtime is written in C so to get started quickly enough you'll need an existing libc and libfb. But nobody stops you from implementing those in Freebasic itself - its capable enough.
AJ wrote:I believe Combuster created a kernel in FreeBasic. IIRC he did this as a test rather than for a "production" kernel (correct me if I'm wrong...). In fact, the wiki contains a FreeBasic Barebones kernel. Just don't expect to find too many tutorials / code samples if you get stuck, though :)
I wrote the barebones to smite the heretics (will not give names) :twisted:
My own OS doesn't use Basic for the kernel, it does however use it for the drivers and software.
If you get a bit further, code snippets here
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Craze Frog
Member
Member
Posts: 368
Joined: Sun Sep 23, 2007 4:52 am

Re: building an os with basic

Post by Craze Frog »

Solar, I hope you are aware that you misquoted his question slightly. He didn't ask if converting basic to c was teorethically possible, but rather if it was feasible for him.

To answer the original question:
My first question is as follows: is it possible to program using basic, and if so how? could I translate basic to c somehow, or is there a way to compile basic to a binary like with c. any help would be appreciated.
Yes, you can compile basic to C. The compiler that does this is called BCX.
Yes, you can compile basic to binary code, the FreeBasic compiler does this. However, I think FreeBasic isn't a very good basic, because it has a very C-like feel to it. It's not really BASIC, it's C with BASIC syntax (and in some cases, C syntax).

Yes, you can write your OS in BASIC. But you'll have to use quite a bit of assembly code, and most of the friendly BASIC features will not available unless you write them yourself in assembly or C (as you said yourself).
terry
Posts: 13
Joined: Tue Mar 17, 2009 12:43 pm

Re: building an os with basic

Post by terry »

Pasha wrote:I did check the search engine first. I typed in basic language and only got things about basic C and basic concepts, and I went through two pages of that kind of stuff before I went to the trouble of starting a new thread. I am sorry, I will look harder.
Yeah, I've also noticed that the Search functionality of this site isn't very good. What I tend to do is go to google and type, "site:osdev.org X" where X is my query. For example, typing, "site:osdev.org program kernel with basic", returns a list where not everything is relevant, but the first hit is the tutorial on doing a BareBones kernel with FreeBasic.

Hope this helps other people who try to search the forums.
Pasha
Posts: 10
Joined: Fri Dec 19, 2008 10:56 am

Re: building an os with basic

Post by Pasha »

I downloaded BCX for Windows, but it won't run, does anyone know if it depends on other files being present. it gave me some error about ldd. any ideas?
Pasha
Posts: 10
Joined: Fri Dec 19, 2008 10:56 am

Re: building an os with basic

Post by Pasha »

never mind, I got it working. tnkx!
Pasha
Posts: 10
Joined: Fri Dec 19, 2008 10:56 am

Re: building an os with basic

Post by Pasha »

If I have my source code in c, then what I have to do next, is to translate the .h files that bcx inserts into my file into assembly. This i assume will be a long and grueling process. I also assume that no one here has tried to do the same thing already and could give me some pointers. Please correct me, I hope I am wrong. :mrgreen:
Post Reply