Forum > Other
Far pointer versus Pointer in 16-bit DOS
aitorsm:
Hello,
I used to code with TP for 16-bit and FPC for 32-bit DOS, so I was very happy to know that finally there's a 16-bit flavour of FPC, so I can use an actively supported compiler.
I am trying to re-compile FD-KEYB under FPC 16-bit (under a Win32 host OS). It compiles fine under TP, but I get a bunch of errors when trying to compile for FPC 16-bit, so trying to see how to overcome them.
FD-KEYB is a complex stuff to recompile, it has a lot of pointer and memory mangling, and most of the resident code is inlined assembler. For compatibility, I hope that the inlined assembler is taken as TASM-compatible and not NASM-compatible.
So here I go with the first question: most of the errors I get are about incompatibility between Pointers and Far pointers:
Incompatible types: got "FarPointer" expected "Pointer"
Incompatible types: got "Pointer" expected "FarPointer"
Illegal type conversion: "FarPointer" to "pword"
So how does FPC handle FarPointers? In TP I never had to care because all pointers were by default Far, but for FPC I see I have to care.
Thanks in advance,
Aitor
Leledumbo:
I believe it's highly dependent on the chosen memory model. You might need compact, large or huge to make Pointer = FarPointer.
PascalDragon:
In addition to what Leledumbo wrote (which is correct) you also need to compile the RTL with the correct memory model assuming you did compile FPC yourself and didn't use the installer provided with FPC 3.2.2 (which contains all memory models precompiled; then just specifying the memory model should be enough to pick the correct units).
aitorsm:
Hello,
As the program is less than 50K (before UPX-ing), I chose the Tiny memory model:
ppcross8086 -WmTiny -WtEXE -Sg KEYB.PAS
Wouldn't that make ALL pointers near?
I haven't precompiled the compiler, I am using the 3.2.2 distribution.
I have to use -Sg, because I am using LABEL/GOTO at some points.
To add more context information:
I don't get cross incompatibilities between my code and the standar units, but between my code itself:
Var
MultiHand : Pointer;
...
MultiHand := ptr (ResCS,ofs(Int2Fh));
gives me a:
KEYB.PAS(2656,17) Error: Incompatible types: got "FarPointer" expected "Pointer"
That suggests that the ptr construct returns a FAR pointer, whereas Pointer is NEAR pointer.
I need it to be far to be able to check the installed handler;
Var IntVec : Array[Byte] of Pointer absolute 0:0;
...
if not ( (IntVec[$2F]=MultiHand)...
as I wanted to bypass DOS. I'll try and see if using GetIntVec and passing MultiHand would make it any better, but I'd need that both SEG:OFS of the interrupt vector table coincides (not just the OFS).
Or alternatively, treating all them as double words instead of pointers.
Aitor
marcov:
Anything CS:Offset is per definition a far pointer, as a near pointer is only the 16-bit offset within the segment.
IOW you are using FAR pointer constructors like ptr() and FAR variables like IntVec (outside the datasegment, probably), but define a NEAR pointer (multihand) to work with it.
That does not make sense. Maybe declaring multihand FAR will fix this.
Navigation
[0] Message Index
[#] Next page