Pascal: Difference between revisions

Jump to navigation Jump to search
no edit summary
[unchecked revision][unchecked revision]
(fix erroneous qword info in multiboot.pas)
No edit summary
Line 1:
== Historical note ==
Historical note: The original Standard Pascal was in many ways a different language from the Object Pascal that most people today are familiar with, being much simpler but also more limited. Dr. Wirth himself did not intend Pascal for systems programming, and his ongoing language evolution were the languages Modula-2 and Oberon. Both languages are related to Pascal in a similar way as C++, C# and Java are related to C. In contrast to the C language family, in the course from Pascal to Oberon the language definition got a lot more compact, but the language itself got more powerful. Oberon-2 supports all concepts of object-oriented programming. The successors of Pascal were developed to address the weaknesses of Pascal in this regard. However, with the widespread adoption of the Object Pascal extensions (e.g.. unit, bitwise operators), many of these weaknesses (most specifically the lack of support for separate compilation) were eliminated. The reputation of Pascal as a toy language has unfairly persisted in many places however.
The original Standard Pascal was in many ways a different language from the Object Pascal that most people today are familiar with, being much simpler but also more limited.
 
Dr. Wirth himself did not intend Pascal for systems programming, and his ongoing language evolution were the languages Modula-2 and Oberon. Both languages are related to Pascal in a similar way as C++, C# and Java are related to C. Oberon-2 supports all concepts of object-oriented programming. In contrast to the C language family, in the course from Pascal to Oberon the language definition got a lot more compact, but the language itself got more powerful.
 
The successors of Pascal were developed to address the weaknesses of Pascal in this regard. However, with the widespread adoption of the Object Pascal extensions (e.g.. unit, bitwise operators), many of these weaknesses (most specifically the lack of support for separate compilation) were eliminated. The reputation of Pascal as a toy language has unfairly persisted in many places however.
 
Oberon as a successor of Pascal has been used extensively to develop and research Operating Systems (see [http://www.oberon.ethz.ch/ Native Oberon] and [http://bluebottle.ethz.ch BlueBottle]).
Line 5 ⟶ 10:
Pascal had been used in early Apple Macs as implementation language.
 
== Commonly used tools ==
The most popular pascal compilers today seems to be Delphi and FreePascal Compiler, and to a smaller extent Turbo Pascal. To date no operating system has been written in Delphi. Although it may be theoretically possible, it seems to be too much work hacking the resulting executable into a working OS
 
FPC(FreePascal Compiler) is more suited to the job as it's highly configurable and generates code to a great number of platforms
 
== Interfacing Pascal with Assembler. ==
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
 
Line 64 ⟶ 69:
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 ==
credit flies to De Deyn Kim for the freepascal, public domain version of BareBones.
 
Line 240 ⟶ 245:
</pre>
 
=== console.pas ===
 
<pre>
Line 452 ⟶ 457:
</pre>
 
=== system.pas ===
<pre>
unit system;
Line 471 ⟶ 476:
</pre>
 
===linker Linker script ===
linker.script
<pre>
Line 507 ⟶ 512:
</pre>
 
=== Linking ===
Link the whole thing with:
ld -Tlinker.script -o kernel.obj stub.o kernel.o multiboot.o system.o console.o
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu