OSDev.org
https://forum.osdev.org/

OS Development in other languages II : Am i going in the rig
https://forum.osdev.org/viewtopic.php?f=1&t=11192
Page 1 of 1

Author:  MSTR [ Fri Dec 23, 2005 8:39 am ]
Post subject:  OS Development in other languages II : Am i going in the rig

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

Author:  JAAman [ Fri Dec 23, 2005 9:01 am ]
Post subject:  Re:OS Development in other languages II : Am i going in the

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

Author:  Dex4u [ Fri Dec 23, 2005 9:03 am ]
Post subject:  Re:OS Development in other languages II : Am i going in the

Here is a beginner guide, to making a "pascal hello world! OS "
Step 1. write this:
Code:
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 ??.

Author:  Pype.Clicker [ Fri Dec 23, 2005 10:03 am ]
Post subject:  Re:OS Development in other languages II : Am i going in the

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.

Author:  MSTR [ Fri Dec 23, 2005 11:03 am ]
Post subject:  Re:OS Development in other languages II : Am i going in the

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

Author:  bubach [ Fri Dec 23, 2005 11:45 am ]
Post subject:  Re:OS Development in other languages II : Am i going in the

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

Author:  Dex4u [ Fri Dec 23, 2005 3:15 pm ]
Post subject:  Re:OS Development in other languages II : Am i going in the

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.

Author:  MSTR [ Sat Dec 24, 2005 1:30 pm ]
Post subject:  Re:OS Development in other languages II : Am i going in the

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

Author:  Dex4u [ Sat Dec 24, 2005 2:40 pm ]
Post subject:  Re:OS Development in other languages II : Am i going in the

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.

Author:  Kim [ Sun Dec 25, 2005 5:53 am ]
Post subject:  Re:OS Development in other languages II : Am i going in the

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

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/