OSDev.org

The Place to Start for Operating System Developers
It is currently Tue May 07, 2024 9:05 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: OS Development in other languages II : Am i going in the rig
PostPosted: Fri Dec 23, 2005 8:39 am 
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


Top
  
 
 Post subject: Re:OS Development in other languages II : Am i going in the
PostPosted: Fri Dec 23, 2005 9:01 am 
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


Top
  
 
 Post subject: Re:OS Development in other languages II : Am i going in the
PostPosted: Fri Dec 23, 2005 9:03 am 
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 ??.


Top
  
 
 Post subject: Re:OS Development in other languages II : Am i going in the
PostPosted: Fri Dec 23, 2005 10:03 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 2:31 am
Posts: 5964
Location: In a galaxy, far, far away
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.

_________________
Image May the source be with you.


Top
 Profile  
 
 Post subject: Re:OS Development in other languages II : Am i going in the
PostPosted: Fri Dec 23, 2005 11:03 am 
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


Top
  
 
 Post subject: Re:OS Development in other languages II : Am i going in the
PostPosted: Fri Dec 23, 2005 11:45 am 
Offline
Member
Member
User avatar

Joined: Sat Oct 23, 2004 11:00 pm
Posts: 1223
Location: Sweden
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


Top
 Profile  
 
 Post subject: Re:OS Development in other languages II : Am i going in the
PostPosted: Fri Dec 23, 2005 3:15 pm 
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.


Top
  
 
 Post subject: Re:OS Development in other languages II : Am i going in the
PostPosted: Sat Dec 24, 2005 1:30 pm 
<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>


Top
  
 
 Post subject: Re:OS Development in other languages II : Am i going in the
PostPosted: Sat Dec 24, 2005 2:40 pm 
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.


Top
  
 
 Post subject: Re:OS Development in other languages II : Am i going in the
PostPosted: Sun Dec 25, 2005 5:53 am 
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


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 16 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group