Page 1 of 2
New Operating System with PureBasic? [SOLVED]
Posted: Thu May 01, 2008 11:58 am
by BigJack
Hi all;
I was wondering if it was possible to create a new stand-alone operating system with PureBasic?

Posted: Thu May 01, 2008 12:02 pm
by ts-soft
PureBasic requires a OS for running his executable, so it's not possible to create a OS

Posted: Thu May 01, 2008 1:56 pm
by Fluid Byte
If you would really have the needed knowledge you wouldn't ask this question.

Posted: Thu May 01, 2008 2:05 pm
by Trond
There was a topic about this in the off topic section, but I can't find it.
Posted: Thu May 01, 2008 2:39 pm
by Rook Zimbabwe
There was a book titled
Developing Your Own 32bit Operating System Which had extensive chapters on the ASM necessary... An example CD as well...
Now I doubt it could fully work in PB, but it would be interesting to try.
http://www.amazon.com/Developing-32-Bit ... 125&sr=8-1
Hey inline ASM must be good for other things too!

Posted: Thu May 01, 2008 3:22 pm
by Inf0Byt3
I remember asking this question too, but it is almost impossible. PB uses API calls to accomplish tasks that are only found in DLLs that ship with Windows. The base of an OS must be made in ASM and then you can switch to something more high-level. But an OS is the hardest thing you can try to do.
Posted: Thu May 01, 2008 4:02 pm
by Rook Zimbabwe
There was a program called bootloader.exe that would copy boot.bin to the bootsector. You could rename boot.exe to boot.bin. or look for another program called exe2bin...
Code: Select all
; This is a comment
[ORG 0x7C00] ;This just tells the program where it is in the memory. Not important
[BITS 16] ;Not important too.
jmp start ; Jump over BIOS parameter block
start: ;The label for the start of the actual program
push cs ;Put cs onto the stack
pop ds ;Take it out and put it into ds
mov si,Print_loading ;Print loading message
call printstring ;Call is like jump, but it goes back. Like a function
;The complicated bit: Loads the next program
mov ah,02h ;When ah=, int13 reads a disk sector
mov al,4 ;Al is how many sectors to read
mov ch,0 ;The track to read from
mov cl,2 ;Sector Id
mov dh,0 ;Head
mov dl,0 ;Drive (0 is floppy)
mov bx,0x1000 ;Es and Bx put together are where to load the program too (see jmp 0x1000:0x00)
mov es,bx
mov bx,0x00
int 13h ;Int 13 is all functions for disks
mov si,putdot ;Print a ".".
call printstring
jmp 0x1000:0x00 ;Run Bootinit from stack.
printstring: ;Print string routine.
mov ah,0eh ;Mov ah into 0, so int 10 prints
stringloop: ;The following code loads each seperate charcter so it can be printed
lodsb
cmp al,00 ;If al =0, then the string has all been loaded
je endstring
int 10h ;When int 10 is called, and ah=, it prints
jmp stringloop
endstring:
ret ;Ret returns
putdot db '.',0
Print_loading db 13,10,'Loading Pure OS v0.01a...',0
times 425 db 0 ;wastes 425 bytes on purpose, so the sector is full (The program must be 512 bytes long)
Code is not mine... scrummed off the web... but that is the basics of boot.bin in ASM. I used it one summer in IT classes at Rice University... Got a B+ in the course because I did things my own way and the Prof. Had a large corncob up his rear!
:roll:
Code posted as an example
ONLY!!!
Code was "borrowed" from here:
http://www.groovyweb.uklinux.net/index. ... 20own%20os
Let us know what happens...
I wouldn't do this to your own computer!
OR
You could just figure out how to use the DARWIN core of OsX and build a MacLike OS that can run Crapintosh programs!

Posted: Thu May 01, 2008 6:15 pm
by BigJack
Thanks for your replies...
Well, I almost thought so myself that developing an 32 bit/64bit OS won't be feasable using PB itself.
A friend of mine asked me to post this request in our forum to make sure.
If you would really have the needed knowledge you wouldn't ask this question.
I personally don't possess the knowledge nor the capabilities to get a project like this started in the first place, but I found
the idea itself quite interesting, nevertheless.
But just imagine what would happen to PureBasic if someone was able to
find a way to accomplish this...
Posted: Thu May 01, 2008 6:49 pm
by Fluid Byte
Well, of course you can do anything but it's always a question of the effort you want to invest.
There are probaly better alternatives to write an OS than an indie BASIC dialect.
Posted: Thu May 01, 2008 7:12 pm
by X
The short answer is yes, you can create an OS with PB. The long answer is ..
1. You need to create a boot loader in pure ASM, and some of th kernel.
2. You need to port over FASM.
3. You need to write your own PB libraries and front end compiler to run against FASM.
Once all of that is completed, then you can use PB to create the test of the OS.
Posted: Thu May 01, 2008 11:13 pm
by Heathen
Considering how much purebasic functions rely on your OS, I don't think it would have much of a point as most of your code will have to be written in ASM anyhow. The main purpose of PB is to act as a layer between you and your OS to simplify otherwise complicated tasks. If you don't use any of those functions, it would be kinda pointless using PB, since that's really what makes PB what it is.
Posted: Thu May 01, 2008 11:34 pm
by BigJack
Well, I guess that's true.
It was a hypothetical question anyways - and it has been answered...
I had never thought this topic would yield that much response.
Thanks to all of you for stating your opinion about this.

Posted: Fri May 02, 2008 1:53 am
by pdwyer
X wrote:The short answer is yes, you can create an OS with PB. The long answer is ..
1. You need to create a boot loader in pure ASM, and some of th kernel.
2. You need to port over FASM.
3. You need to write your own PB libraries and front end compiler to run against FASM.
Once all of that is completed, then you can use PB to create the test of the OS.
This is not quite true (I don't think - but I could be wrong)
The boot loader doesn't have to be written in ASM, it just has to be machine code and obviously not have dependancies on an existing OS infrastructure. How it got from a source code base to binary is largely irrelevent.
After this loader is running, you might be able to use PB to make some progress, it would be hard to tell (for me) how crippled PB would be without an underlying OS though. If the basic file IO uses the OS for file operations (which I would guess is the case) then PB isn't going to get far.
the first Unix was apparently written in ansi C. A step away from using ASM
Posted: Fri May 02, 2008 3:06 pm
by Rook Zimbabwe
But VC is a valid tool for writing an OS.
PB is written in VC;
therefore PB is a valid tool for writing an OS.
(Any language that compiles to machine code can write an OS if you know where to POKE and PEEK things!)
I remember that at least two of the ATARI OS was written in ATARI BASIC and ASM... BatOS was one.
That pundited... I would not like to undertake such a herculean task. Once you get past the boot and the loader, you have the wall of programming the file system. Then it is probably time for pure ASM or VC! Or you could simply rebuild an OS by plugging in to an existing kernel.

Posted: Fri May 02, 2008 3:39 pm
by Trond
Rook Zimbabwe wrote:But VC is a valid tool for writing an OS.
PB is written in VC;
therefore PB is a valid tool for writing an OS.
That's like:
VC is a valid tool for writing an OS
Unreal Tournament 2002 is written in VC
Therefore, Unreal Tournament 2002 is a valid tool for writing an OS!
