Page 1 of 1
Wiki pascal code doesn't compile
Posted: Fri May 02, 2008 9:11 am
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.
Posted: Fri May 02, 2008 10:05 am
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
Posted: Mon May 26, 2008 12:26 am
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).
Posted: Tue May 27, 2008 8:55 am
by inflater
Well, did you switch to protected mode?
Posted: Tue May 27, 2008 9:58 am
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.
Posted: Wed May 28, 2008 12:39 am
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?).
Posted: Wed May 28, 2008 5:20 am
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".
Posted: Wed May 28, 2008 6:13 am
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.
Posted: Mon Jun 02, 2008 12:36 am
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)?