When porting Turbo Pascal code
The fact that 16-bit code is no longer used, means that some of the older Turbo Pascal constructs and functions are obsolete. The following is a list of functions which shouldn’t be used anymore:
- Seg()
-
: Returned the segment of a memory address. Since segments no longer have meaning, zero is returned in the Free Pascalrun-time library implementation of
Seg. - Ofs()
-
: Returned the offset of a memory address. Since segments have no more meaning, the complete address is returned in the Free Pascalimplementation of this function. This has as a consequence that the return type is
longintorint64instead ofWord. - Cseg(), Dseg()
-
: Returned, respectively, the code and data segments of your program. This returns zero in the Free Pascalimplementation of the system unit, since both code and data are in the same memory space.
- Ptr
-
: Accepted a segment and offset from an address, and would return a pointer to this address. This has been changed in the run-time library, it now simply returns the offset.
- memw and mem
-
: These arrays gave access to the DOSmemory. Free Pascal supports them on the go32v2 platform, they are mapped into DOSmemory space. You need the
go32unit for this. On other platforms, they are not supported
You shouldn’t use these functions, since they are very non-portable, they’re specific to DOSand the 80x86 processor. The Free Pascalcompiler is designed to be portable to other platforms, so you should keep your code as portable as possible, and not system specific. That is, unless you’re writing some driver units, of course.
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
