Anonymous user
Pascal: Difference between revisions
added source tags
[unchecked revision] | [unchecked revision] |
(→Commonly used tools: Introduced ClassiOS (formerly PetrOS®) as an OS developed in Delphi.) |
(added source tags) |
||
Line 21:
Just like when Doing a kernel in C++, Pascal compilers mangle functions name to make them convey more information (such as arguments and return types). That means if you just write
<source lang="pascal">
unit KernelMain;
Line 34:
end.
</
You may end up with "THREADVARLIST_P$KERNEL_MAIN" rather than just "kernel_main" as a function name. If you're using FreePascal, the tool <tt>objdump</tt> can show you the symbol table of the .o file generated by the compiler, which will give you the "real" name of the function.
Line 40:
Alternatively, you could use compiler extra statements to enforce a "public name" to your function:
<source lang="pascal">
unit KernelMain;
Line 53:
end.
</
Finally, simply declaring a program like you would when writing Pascal code for any normal platform will create a main routine named PASCALMAIN.
<source lang="pascal">
program Kernel;
Line 68:
{Your kernel here.}
end.
</
Note, too, that C and PASCAL doesn't share the same calling convention. Most notably, arguments in PASCAL are pushed from left to right while C push them from right to left. If this gets you in trouble, you can use cdecl modifier to force the compiler considering that your PASCAL procedure works like a C function (that should mainly be useful to interface pascal code with C code). Moreover, in PASCAL, the callee function is responsible from [[Stack#Stack example on the X86 architecture|stack cleaning]], while this is typically the job of the caller in C/C++ environment.
== Pascal BareBones ==
:''Should we move this to another page? --[[User:Troy martin|Troy Martin]] 04:42, 10 July 2009 (UTC)''
Credit flies to De Deyn Kim for the freepascal, public domain version of BareBones.
Line 81 ⟶ 82:
=== stub.asm ===
<source lang="asm">
;/////////////////////////////////////////////////////////
;// //
Line 161 ⟶ 162:
KERNEL_STACK:
resb KERNEL_STACKSIZE
</
=== kernel.pas ===
<source lang="pascal">
{
/////////////////////////////////////////////////////////
Line 235 ⟶ 236:
end.
</
=== console.pas ===
<source lang="pascal">
{
/////////////////////////////////////////////////////////
Line 386 ⟶ 387:
end.
</
=== multiboot.pas ===
<source lang="pascal">
unit multiboot;
Line 445 ⟶ 446:
end.
</
=== system.pas ===
<source lang="pascal">
unit system;
Line 464 ⟶ 465:
end.
</
=== Linker script ===
|