FreePascal help
Re:FreePascal help
Could anyone of you guys post a simple non-multiboot Hello world kernel code in freepascal ? thanx a lot
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:FreePascal help
<preprocessing>John Goodman wrote: Could anyone of you guys post a simple non-multiboot Hello world kernel code in freepascal ? thanx a lot
Do anyone of you guys happen to have a simple, non-multiboot Hello wolrd kernel in freepascal and wish to share it here ?
</preprocessing>
What would be the point ? it would be dependent of the bootloader, it would be harder to reuse or to guess what has to be done, etc.
Well, if anyone has, it's welcome anyway, but really, i don't see what it would add but tons of .ASM files ...
Re:FreePascal help
1. I installed FreePascal 2.0.0 for Win32, and tried to compile a program which had some assembler code in it, and the compiler failed. It said that it couldn't find NASM. How can I fix this problem ?
2. why is there so little tutorials on writing kernels in Pascal on the internet ?
2. why is there so little tutorials on writing kernels in Pascal on the internet ?
Re:FreePascal help
1) At a guess, get NASM from nasm.sourceforge.net and put it in the program directory.
2) Because Pascal is an "off the beaten track" language. It is rarely used in production projects, C/C++ is the industry standard for general software development.
2) Because Pascal is an "off the beaten track" language. It is rarely used in production projects, C/C++ is the industry standard for general software development.
Re:FreePascal help
How can that be? Freepascal 2.0 uses an internal assembler... anyway thats what the developers told me... make sure you tell the compiler you are using intel / gnu as style asm....just a stranger wrote: 1. I installed FreePascal 2.0.0 for Win32, and tried to compile a program which had some assembler code in it, and the compiler failed. It said that it couldn't find NASM. How can I fix this problem ?
2. why is there so little tutorials on writing kernels in Pascal on the internet ?
Re:FreePascal help
Disclaimer: I actually applaud anyone who believes in his favourite language strongly enough to actually tackle the difficulties of adapting it for OS work. What I write below is what I perceive to be the majority point of view, not (necessarily) my own.just a stranger wrote: 2. why is there so little tutorials on writing kernels in Pascal on the internet ?
Be aware that many people would consider the notion of writing an OS in Pascal to be comparable to writing a web browser in PHP: It "feels" to be the wrong way around, the wrong tool for the job, with the (implied or expressed) sidenote that the person talking about such a project is a noob who is hellbent on this one language simply because he knows no other.
Pascal is a language widely used in teaching beginners how to code. Later generations of the language (Delphi) have been used for rapid application development (RAD). But at no point has Pascal earned any fame as being "well suited" to the type of low-level bit fiddling required by OS developent...
The canonical languages for this are Assembler and C, simply because they have zero runtime requirements, and offer plenty of bit-fiddling primitives. Just about any compiler can turn these source languages into plain binaries (which is what you need for kernel development). That's why virtually every tutorial out there assumes ASM / C.
Of course it is possible to write an OS in Pascal. But it adds a level of difficulty to an already difficult job, for an arguable benefit. Even C++-kernel-tutorials are rare (as I came to discover when attempting to write a C++ kernel), and I'd argue that C++ is much more suited to the task (probably even more so than C).
Every good solution is obvious once you've found it.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:FreePascal help
to illustrate what Solar says, think of interrupt/segment descriptors. They have ugly memory representation, they need ASM command to be loaded, etc. How can you go through this with pascal ?
- use inline assembly (quite a bunch of it for those parts)
- use a plain assembly function that does something sufficiently smart so that you can pass it atomic arguments.
How would you, for instance represent a page table entry (we need it often enough so that we don't get bored with asm functions/inline for that). There are bits here and there that you want to address separately (the struct {unsigned present:1, unsigned11, unsigned paddr:20}; declaration in C, for instance, makes it nicer to deal with)
- use inline assembly (quite a bunch of it for those parts)
- use a plain assembly function that does something sufficiently smart so that you can pass it atomic arguments.
How would you, for instance represent a page table entry (we need it often enough so that we don't get bored with asm functions/inline for that). There are bits here and there that you want to address separately (the struct {unsigned present:1, unsigned11, unsigned paddr:20}; declaration in C, for instance, makes it nicer to deal with)
Re:FreePascal help
JMP and CALL with selector is now supported.
too long urls trash board display
GDT structs are defined like this for me (from old kernel, I started a new one):
About page entry's i am not sure, but for my init code in the new kernel i am using DWORDs and bitwise operations, i'll have to take a look at freepascal's docs to see if theyr is a better solution (inline functions should work).
too long urls trash board display
GDT structs are defined like this for me (from old kernel, I started a new one):
Code: Select all
Pgdtr = ^gdtr_t;
gdtr_t = packed record
limit: WORD;
base_addr: DWORD;
end;
Pgdtd = ^gdtd_t;
gdtd_t = packed record
limit_part1: WORD;
base_addr_part1: WORD;
base_addr_part2: BYTE;
opt_part1: BYTE;
limit_opt_part2: BYTE;
base_addr_part3: BYTE;
end;
//GDT_KERNEL_CODE
default_gdt[GDT_KERNEL_CODE_IDX].limit_part1 := GDT_KDF_LIMIT_PART1;
default_gdt[GDT_KERNEL_CODE_IDX].base_addr_part1 := GDT_KDF_BASE_ADDR_PART1;
default_gdt[GDT_KERNEL_CODE_IDX].base_addr_part2 := GDT_KDF_BASE_ADDR_PART2;
default_gdt[GDT_KERNEL_CODE_IDX].opt_part1 := GDT_KDF_CODE_OPT_PART1;
default_gdt[GDT_KERNEL_CODE_IDX].limit_opt_part2 := GDT_KDF_LIMIT_OPT_PART2;
default_gdt[GDT_KERNEL_CODE_IDX].base_addr_part3 := GDT_KDF_BASE_ADDR_PART3;