Wiki pascal code doesn't compile

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
User avatar
inflater
Member
Member
Posts: 1309
Joined: Thu Sep 28, 2006 10:32 am
Location: Slovakia
Contact:

Wiki pascal code doesn't compile

Post by inflater »

Compiling the example code in this:
http://www.osdev.org/wiki/Pascal

will result in "Cant find unit SYSTEM". Anybody know what is wrong?

I'm using the latest version of FPC.
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English :P)
User avatar
inflater
Member
Member
Posts: 1309
Joined: Thu Sep 28, 2006 10:32 am
Location: Slovakia
Contact:

Post by inflater »

OK, I found that you need the system.pas in the attachment.

This is my COMPILE.BAT contents which works, please note I stripped off the multiboot routines from the sources and my kernel starts from real mode, the resulting application will be in a MZ (DOS-EXE) format. Anyways, it looks pretty stoopid but works like a charm. ;)

Code: Select all

del *.o *.s *.ppu
nasm -f obj stub.asm -o stub.obj
fpc -a -Atasm -n -O3 -Op3 -Si -Sc -Sg -Xd -Tlinux -Rintel kernel.pas
tasm console.s console.o
ren *.o *.obj
valx /32 stub.obj kernel.obj system.obj console.obj,KERNEL.BIN,,,
del *.obj *.o *.map *.s *.ppu
//EDIT 2: This now works correctly. :)

I hope this helps somebody. :)

Regards
inflater
Attachments
system.zip
(651 Bytes) Downloaded 137 times
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English :P)
leledumbo
Member
Member
Posts: 103
Joined: Wed Apr 23, 2008 8:46 pm

Post by leledumbo »

I've made it compiled without system.zip you provided, but by adding libpsystem.a from i386-linux units directory to ld. I'll try your system unit. My question is: How can I boot it? I'm using Qemu and it won't boot either by supplying it as diskette (-fda) or cd (-cdrom).
User avatar
inflater
Member
Member
Posts: 1309
Joined: Thu Sep 28, 2006 10:32 am
Location: Slovakia
Contact:

Post by inflater »

Well, did you switch to protected mode?
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English :P)
nick8325
Member
Member
Posts: 200
Joined: Wed Oct 18, 2006 5:49 am

Post by nick8325 »

It's a Multiboot kernel, which means you need to use GRUB to boot it. If you need any help setting that up, just ask.
leledumbo
Member
Member
Posts: 103
Joined: Wed Apr 23, 2008 8:46 pm

Post by leledumbo »

Well, did you switch to protected mode?
How?
If you need any help setting that up, just ask.
I'm asking it then, what do I do first? I really have no idea that it has something todo with GRUB as the wiki doesn't mention it (although I think it's right, how can a bare hardware run elf32 executable?).
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

leledumbo wrote:
Well, did you switch to protected mode?
How?
If you need any help setting that up, just ask.
I'm asking it then, what do I do first? I really have no idea that it has something todo with GRUB as the wiki doesn't mention it (although I think it's right, how can a bare hardware run elf32 executable?).
First, you type the word "GRUB" into the wiki search box.

Second, you press "enter".
nick8325
Member
Member
Posts: 200
Joined: Wed Oct 18, 2006 5:49 am

Post by nick8325 »

You can download a floppy disk image with GRUB on it from here. You'll need to copy the kernel onto the disk image using e.g. mtools or WinImage. Then create a file called menu.lst in the boot/grub directory of the image with the contents

Code: Select all

title OS
kernel /the-file-name-of-the-kernel
Now qemu should be able to boot the image.
leledumbo
Member
Member
Posts: 103
Joined: Wed Apr 23, 2008 8:46 pm

Post by leledumbo »

Yippie! Thank you, it boots correctly now. Though there's some weirdness in wiki instruction here:
Important: first check the size of your kernel.bin in blocks. This is the length in bytes, divided by 512 and rounded up to the next integer.
My kernel is 21.4 KB (21,999 Bytes), so it should have Round(21,999 / 512) = 43 blocks. But qemu hangs if I tell kernel 200+43. Crazily, I tried 18 (as an ASSUMPTION written there) and voila! It works, even though qemu says there're some bad blocks, but who cares?!

One last question, can anyone point me where to go from here (doesn't matter if it's in C or others, converting between languages is my daily life)?
Post Reply