OS Development in other languages II : Am i going in the rig

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

OS Development in other languages II : Am i going in the rig

Post by MSTR »

Ok..here is a nice question. I have here a simple bootloader code that I've found in a site. It boots a simple 'kernel' in ASM too, that displays a "Hello World" message on screen You don't need to read the bootloader, just the kernel:
-----bootloader---------------
ORG 7C00h]      

inicio:
;
cli         
mov ax, 0x9000      
mov ss,
mov sp, 0      
sti         


mov [bootdrv], dl   
call carregar      
jmp far 1000h:0      

;
bootdrv db 0      
carregar:
push ds      
.reset:
mov ax, 0      
mov dl, [bootdrv]   
int 13h      
jc .reset      
pop ds         

.leitura:
mov ax,0x1000      
mov es,ax      
mov bx, 0      
         
mov ah, 2      
mov al, 5      
mov cx, 2      
mov dh, 0      ;
mov dl, [bootdrv]   
int 13h      
jc .leitura      ;

retn      ;

times 512-($-$$)-2 db 0   ;
dw 0AA55h      ;
----------------"KERNEL"------------------------------
mov ax, 1000h      ;
mov ds, ax      ;
mov es, ax      ;

mov si, msg      
call poeString      
loopp:      
jmp loopp

poeString:
lodsb         
or al,al      
jz short volta      
mov ah,0x0E      
mov bx,0x0007      
int 0x10      
jmp poeString      
volta:
retn         
msg db 'Operating System Test IIIIIII',13,10,0
----------------------------------------------------

OK.. IT WORKS.....I tested and everything is OK. My question is if can I make the kernel in other language like Pascal. Here is how I want to do it:
1: Write a simple program in Pascal that display a message on screen
2: Put a inline assembly code in the beggining of my Pascal program :
mov ax, 1000h      ;
mov ds, ax      ;
mov es, ax      ;
3:Compile to EXE.
4:Use EXE2BIN to convert my .EXE to a .BIN file
5:Write the bootloader and this new 'kernel" in a floopy with PartCopy like a did before.
-------
Am i going in the right direction? Will it work or everything I wrote is crap??
PLZ HELP me...
thanks...:P
JAAman

Re:OS Development in other languages II : Am i going in the

Post by JAAman »

you could, but be sure not to use any of the built-in functions, as these will all assume a specific underlying OS

then youll need to load it, and find the appropriate entry point to jump to
Dex4u

Re:OS Development in other languages II : Am i going in the

Post by Dex4u »

Here is a beginner guide, to making a "pascal hello world! OS "
Step 1. write this:

Code: Select all

 program Hello;
?
 uses
 ???crt;
 begin
 ???ClrScr;
 ???Write('Hello world');
 ???Readln;
 end. 
Step 2.
Make it into a exe called, "kernel32.exe"
Step 3.
Go here here: http://www.dex4u.com/
and get Dex.zip, when you click on the exe, in the zip, it will put a bootloader + my OS on a floppy, you can delete all these files if you want, including a file called "kenel32.exe" and put the one you made above on the floppy and reboot.

And with luck you should have your first pascal "hello world! OS :) .

Good luck.
PS: The above is using turbo pascal, not freepascal.
Also do not forget to use "uses crt;" as for some reason, with it the functions do not need dos, but with out it they do ??, all most as if, they want a OS independent compiler ability ??.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:OS Development in other languages II : Am i going in the

Post by Pype.Clicker »

http://www.mega-tokyo.com/forum/index.p ... eadid=8774

has same question with slightly different comments. Please do not post the same question twice.
MSTR

Re:OS Development in other languages II : Am i going in the

Post by MSTR »

OK.. I will try converting a Pascal program to bin and boot together with that bootloader
I will try right now to download DEX.ZIP, and see if I can boot some Turbo Pascal programs I did. Thank you very much
Sorry to open a different post, i didn't think it was exactly the same question..
anyway,,,, tnx
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Re:OS Development in other languages II : Am i going in the

Post by bubach »

The thing with the bootloader that Dex uses, and his instructions, is that you don't need to convert your .EXE file to anything. He uses abootloader that supports loading of both .EXE and .COM files, as long as they don't use any DOS interrupts. The crt unit uses BIOS for I/O instead of DOS ints, so it's "safe" to use in realmode OS's.

You can take a look at it here: http://alexfru.chat.ru/epm.html#bootprog
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
Dex4u

Re:OS Development in other languages II : Am i going in the

Post by Dex4u »

bubach is right ,you do not need to convert it, it will load a turbo pascal EXE file, as long as its name is "kernel32.exe" in this case.
I thought it easier to try it, by using the one that comes with Dex4u OS, than convert its name, then write it to disk with rawrite etc.
But once you have tyred it, you can download it from that web site, and convert it , to use the name you want.
MSTR

Re:OS Development in other languages II : Am i going in the

Post by MSTR »

<unshout>
Well ... the Dex4u created the disk and i replaced Kernel32.exe and it worked perfectly ... I am going to try with that bootloader i posted too later. anyway, thank you very much

ps: i don't know if i really understood how to use a kernel name other than 'kernel32.exe"
</unshout>

<edit pype>please, don't post message in caps. that's shouting</edit>
Dex4u

Re:OS Development in other languages II : Am i going in the

Post by Dex4u »

Try do that with a C compiler , ( do not flame me, i am only joking ;) )
Now that you know it works, go to the link bubach gave you and get "Bootprog.zip" in the zip is full instructions on loading a file by another name.

PS: Some function will not work has they use dos, you will need to test each function, to see or get the asm function code that i got.
Kim

Re:OS Development in other languages II : Am i going in the

Post by Kim »

If you want to start a 32bit pascal os.
You could download a package I created some time ago.
http://users.skynet.be/towp/freepascal_barebone_os.rar
Post Reply