New Operating System with PureBasic? [SOLVED]

Just starting out? Need help? Post your questions and find answers here.
BigJack
User
User
Posts: 76
Joined: Tue May 16, 2006 6:46 am
Location: Germany
Contact:

New Operating System with PureBasic? [SOLVED]

Post by BigJack »

Hi all;
I was wondering if it was possible to create a new stand-alone operating system with PureBasic? :?:
Last edited by BigJack on Thu May 01, 2008 11:35 pm, edited 1 time in total.
Greetings to all the folks back home in the States...
PB4.2 Windows XP SP3
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

PureBasic requires a OS for running his executable, so it's not possible to create a OS :wink:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

If you would really have the needed knowledge you wouldn't ask this question. Image
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

There was a topic about this in the off topic section, but I can't find it.
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post 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! :D
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post 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.
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post 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! :wink:
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
BigJack
User
User
Posts: 76
Joined: Tue May 16, 2006 6:46 am
Location: Germany
Contact:

Post 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. :D

But just imagine what would happen to PureBasic if someone was able to
find a way to accomplish this...
Greetings to all the folks back home in the States...
PB4.2 Windows XP SP3
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post 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.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
X
Enthusiast
Enthusiast
Posts: 311
Joined: Tue Apr 04, 2006 6:27 am

Post 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.
Heathen
Enthusiast
Enthusiast
Posts: 498
Joined: Tue Sep 27, 2005 6:54 pm
Location: At my pc coding..

Post 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.
I love Purebasic.
BigJack
User
User
Posts: 76
Joined: Tue May 16, 2006 6:46 am
Location: Germany
Contact:

Post 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. 8)
Last edited by BigJack on Tue May 06, 2008 7:15 am, edited 1 time in total.
Greetings to all the folks back home in the States...
PB4.2 Windows XP SP3
User avatar
pdwyer
Addict
Addict
Posts: 2813
Joined: Tue May 08, 2007 1:27 pm
Location: Chiba, Japan

Post 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
Paul Dwyer

“In nature, it’s not the strongest nor the most intelligent who survives. It’s the most adaptable to change” - Charles Darwin
“If you can't explain it to a six-year old you really don't understand it yourself.” - Albert Einstein
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post 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.

8)
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post 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! :shock:
Post Reply