Re: [Freedos-devel] Problem with procedural types in 16-bit DOS FreePascal

2022-11-08 Thread Aitor Santamaría
Hello Ralf,

On Tue, 8 Nov 2022 at 02:16, Ralf Quint  wrote:

> On 11/7/2022 4:56 PM, Aitor Santamaría wrote:
>
>
> After all, if you declare a procedure to be far is because you want it to
> be called far, right?
>
> I have not tried anything like this with 16bit FPC, but in BP7 (and
> probably before that, but that's +30 years ago  ), procedural parameters
> have always been a far call. As Jerome mentioned, interface'd
> procedures/functions are far by default, as each unit has it's own code
> segment. And if you are using function/procedures within the same unit, you
> have to declare them as FAR. The FAR declaration is only a newer version of
> {$F+} compiler directive, which definitely was needed in TP3, not sure with
> which version of TP/BP this was introduced.
>

KEYB lies in a single PAS file, no units or any fancy stuff.
I am considering to modularise a bit in the future to make it more
readable, via $I, but not in units.

As for FPC, do you explicitly use it in {$MODE TP} mode to be compatible
> with TP/BP? (https://www.freepascal.org/docs-html/user/userse33.html) I
> am not sure right now (don't have an FPC with 16bit option installed
> anywhere here right now) how 16bit FPC is compatible with all those
> compiler options, I just recall that there was mentioned that a lot of the
> newer fluff that had been added to FPC in recent years (interface,
> generics, etc) won't work because of the memory/CPU restrictions imposed...
>
Yeah, as said in the other mails, I have tried using  -MTP when compiling,
which I assume to be equivalent to {$MODE TP}.
The problem mutates in a different casting problem, but is still there.
No fancy new stuff being used in KEYB, it's mostly assembler for the
resident part, and plain Pascal for parsing of the commandline and such.

Aitor
___
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel


Re: [Freedos-devel] Problem with procedural types in 16-bit DOS FreePascal

2022-11-07 Thread Ralf Quint

On 11/7/2022 4:56 PM, Aitor Santamaría wrote:


After all, if you declare a procedure to be far is because you want it 
to be called far, right?
I have not tried anything like this with 16bit FPC, but in BP7 (and 
probably before that, but that's +30 years ago  ), procedural 
parameters have always been a far call. As Jerome mentioned, interface'd 
procedures/functions are far by default, as each unit has it's own code 
segment. And if you are using function/procedures within the same unit, 
you have to declare them as FAR. The FAR declaration is only a newer 
version of {$F+} compiler directive, which definitely was needed in TP3, 
not sure with which version of TP/BP this was introduced.


As for FPC, do you explicitly use it in {$MODE TP} mode to be compatible 
with TP/BP? (https://www.freepascal.org/docs-html/user/userse33.html) I 
am not sure right now (don't have an FPC with 16bit option installed 
anywhere here right now) how 16bit FPC is compatible with all those 
compiler options, I just recall that there was mentioned that a lot of 
the newer fluff that had been added to FPC in recent years (interface, 
generics, etc) won't work because of the memory/CPU restrictions imposed...



Ralf

___
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel


Re: [Freedos-devel] Problem with procedural types in 16-bit DOS FreePascal

2022-11-07 Thread Aitor Santamaría
Hello!

I simplified my email, but this is how it is actually being done :(

Aitor


On Mon, 7 Nov 2022 at 14:38, stefano cirilli  wrote:

> Hi, try to define the variable as a Type:
>
> I googled this:
> Type TOneArg = Procedure (Var X : integer); on
> https://www.freepascal.org/docs-html/ref/refse17.html
> On 07/11/22 01:18, Aitor Santamaría wrote:
>
> Hello,
>
> I am trying to recompile FD-KEYB using 16-bit DOS FreePascal, in order to
> see if I can produce a FPC version and thus avoid using TPC for compiling.
>
> I am not being very lucky with compiling itself, and I haven't raised too
> much attention in the FPC lists, either because it is difficult, or most
> probably, compiling for an old 16-bit OS does not raise too much interest.
>
> So I am trying this list here, in case some of you have ever mangled
> 16-bit FPC and know the answer.
>
> The biggest problem I am having is with the procedural type variables.
> Whereas TPC would swallow this:
>
> VAR
>v: procedure;
>
> procedure P;
> begin
> ...
> end;
>
> v := P;
>
> FPC does not like it, as it is trying to assign the RESULT of P (untyped)
> to v.
>
> KEYB.PAS(2960,21) Error: Incompatible types: got "untyped" expected
> ""
>
> The documentation tells me to use
>
> v := @P;
>
> but it does not work, it gives:
>
> KEYB.PAS(2960,21) Error: Illegal type conversion: " procedure;far;Pascal>" to ""
>
> which puzzles me, because to my  mind, they are the same thing.
>
>
> Using -MTP compiler option does not help, I get lots of new errors, unless
> I avoid it by
>
> TYPE
> SimpleProc = procedure; far; { parameter-less callable
> function }
>
> (which is NOT standard TP language at all), but would in turn give me:
>
> KEYB.PAS(2960,21) Error: Illegal type conversion: " procedure;far;Pascal>" to "NearCsPointer"
>
> You can read the full thread here:
> Far pointer versus Pointer in 16-bit DOS (freepascal.org)
> 
>
>
> Any hints on how to circumvent this problem?
>
> Thanks in advance,
> Aitor
>
>
>
>
> ___
> Freedos-devel mailing 
> listFreedos-devel@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/freedos-devel
>
> ___
> Freedos-devel mailing list
> Freedos-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/freedos-devel
>
___
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel


Re: [Freedos-devel] Problem with procedural types in 16-bit DOS FreePascal

2022-11-07 Thread Aitor Santamaría
Hello,

On Mon, 7 Nov 2022 at 10:12, Rugxulo  wrote:

> Hi,
>
> On Sun, Nov 6, 2022 at 9:08 PM Jerome Shidel  wrote:
> >
> > Make sure your compiling to the correct memory model. (I think huge, but
> you’ll need to double check that)
>
> Default is Small, e.g. "-WmSmall". I assume "-WmCompact" would work
> better for you?
>
It does. It is the mode I am using.


> > You may need to ensure the actual procedure is declared with far.
> >
> > Procedure Test; far;
> > Begin
> > End;
>
> In old freeware TP 5.5, that would be {$F+} at the top and {$F-} at
> the bottom of the procedure. (I believe all procedures within the same
> unit / file are near while external procedures are far by default.)
>
I have tried with ALL the program with {$F+}, and no luck, same error.

Besides, the procedures I am assigning are all FAR. What would be the
difference between these two?

{$F+}
Procedure Test;
Begin
End;
{$F-}

Procedure Test; far;
Begin
End;

After all, if you declare a procedure to be far is because you want it to
be called far, right?


> > Also, you may need assign the address to a plain pointer and typecast
> the call.
>
> Is that needed??
>
Does not help anyway.


> > Also, there are also compiler directives for FPC regarding compatibility.
>
> Default dialect is "fpc", which is less strict than {$mode tp}, e.g.
> it does change function pointer syntax a bit, but it also gives you
> structured return types and function overloading.
>
> {$asmmode intel} is only default for {$mode tp} as well (but you can
> manually enable it, too).
>
Well, instead of a directive, I tried to compile with and without TP mode
(-MTP), and it did not fix it (in the original mail you can see how the
error changed, but still does not compile).
They are both still too strict. I would really love it if two variables of
the same size could be typecasted without any restriction (the programmer
knows).


> Don't forget you can also declare inline functions! (Like real
> inlining, not just inline machine code.)
>
I didn't understand this  ¿?

Aitor
___
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel


Re: [Freedos-devel] Problem with procedural types in 16-bit DOS FreePascal

2022-11-07 Thread Aitor Santamaría
Hello Jerome,


On Mon, 7 Nov 2022 at 04:08, Jerome Shidel  wrote:

> Make sure your compiling to the correct memory model. (I think huge, but
> you’ll need to double check that)
>
Compact is the one that gives me less problems (it's also the one that got
most recommendations :) ).


> You may need to ensure the actual procedure is declared with far.
>
Yeah, all of them are far.

Procedure Test; far;
> Begin
> End;
>
> Also, you may need assign the address to a plain pointer and typecast the
> call.
>
> Type
>   MyProc = procedure;
>
> Var
>   P : pointer;
>
> Begin
> P := @Test;
> MyProc(P^);
> End.
>

I tried that last bit (MyProc(P^)), but no luck:
KEYB.PAS(3382,28) Error: Illegal qualifier
KEYB.PAS(3382,29) Error: Illegal expression


> Also, there are also compiler directives for FPC regarding compatibility.

-MTP did not work :(
It changed the error for another.

Thanks anyway... :(

Aitor
___
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel


Re: [Freedos-devel] Problem with procedural types in 16-bit DOS FreePascal

2022-11-07 Thread Jerome Shidel
Hi Rugxulo,

> On Nov 7, 2022, at 4:11 AM, Rugxulo  wrote:
> 
> Hi,
> 
>> On Sun, Nov 6, 2022 at 9:08 PM Jerome Shidel  wrote:
>> 
>> Make sure your compiling to the correct memory model. (I think huge, but 
>> you’ll need to double check that)
> 
> Default is Small, e.g. "-WmSmall". I assume "-WmCompact" would work
> better for you?
> 
>> You may need to ensure the actual procedure is declared with far.
>> 
>> Procedure Test; far;
>> Begin
>> End;
> 
> In old freeware TP 5.5, that would be {$F+} at the top and {$F-} at
> the bottom of the procedure. (I believe all procedures within the same
> unit / file are near while external procedures are far by default.)

Yes. In TP 5.5/7.0, {$F-} is the default. The default for any 
function/procedure uses near call/return model. Func/Procs in units that are 
declared in the interface section use far call/ret process. 

> 
>> Also, you may need assign the address to a plain pointer and typecast the 
>> call.
> 
> Is that needed??

Most likely not needed. But, if all else fails, it may be something to try. 

>> Also, there are also compiler directives for FPC regarding compatibility.
> 
> Default dialect is "fpc", which is less strict than {$mode tp}, e.g.
> it does change function pointer syntax a bit, but it also gives you
> structured return types and function overloading.
> 
> {$asmmode intel} is only default for {$mode tp} as well (but you can
> manually enable it, too).
> 
> Don't forget you can also declare inline functions! (Like real
> inlining, not just inline machine code.)
> 
> 
> ___
> Freedos-devel mailing list
> Freedos-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/freedos-devel



___
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel


Re: [Freedos-devel] Problem with procedural types in 16-bit DOS FreePascal

2022-11-07 Thread stefano cirilli
Hi, try to define the variable as a Type:

I googled this:
Type TOneArg = Procedure (Var X : integer); on
https://www.freepascal.org/docs-html/ref/refse17.html

On 07/11/22 01:18, Aitor Santamaría wrote:
> Hello,
>
> I am trying to recompile FD-KEYB using 16-bit DOS FreePascal, in order
> to see if I can produce a FPC version and thus avoid using TPC for
> compiling.
>
> I am not being very lucky with compiling itself, and I haven't raised
> too much attention in the FPC lists, either because it is difficult,
> or most probably, compiling for an old 16-bit OS does not raise too
> much interest.
>
> So I am trying this list here, in case some of you have ever mangled
> 16-bit FPC and know the answer.
>
> The biggest problem I am having is with the procedural type variables.
> Whereas TPC would swallow this:
>
> VAR
>    v: procedure;
>
> procedure P;
> begin
> ...
> end;
>
> v := P;
>
> FPC does not like it, as it is trying to assign the RESULT of P
> (untyped) to v. 
>
> KEYB.PAS(2960,21) Error: Incompatible types: got "untyped" expected
> ""
>
> The documentation tells me to use
>
> v := @P;
>
> but it does not work, it gives:
>
> KEYB.PAS(2960,21) Error: Illegal type conversion: " procedure;far;Pascal>" to ""
>
> which puzzles me, because to my  mind, they are the same thing.
>
>
> Using -MTP compiler option does not help, I get lots of new errors,
> unless I avoid it by
>
> TYPE
>         SimpleProc     = procedure; far;     { parameter-less callable
> function }
>
> (which is NOT standard TP language at all), but would in turn give me:
>
> KEYB.PAS(2960,21) Error: Illegal type conversion: " procedure;far;Pascal>" to "NearCsPointer"
>
> You can read the full thread here:
> Far pointer versus Pointer in 16-bit DOS (freepascal.org)
> 
>
>
> Any hints on how to circumvent this problem?
>
> Thanks in advance,
> Aitor
>
>
>
>
> ___
> Freedos-devel mailing list
> Freedos-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/freedos-devel
___
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel


Re: [Freedos-devel] Problem with procedural types in 16-bit DOS FreePascal

2022-11-07 Thread Rugxulo
Hi,

On Sun, Nov 6, 2022 at 9:08 PM Jerome Shidel  wrote:
>
> Make sure your compiling to the correct memory model. (I think huge, but 
> you’ll need to double check that)

Default is Small, e.g. "-WmSmall". I assume "-WmCompact" would work
better for you?

> You may need to ensure the actual procedure is declared with far.
>
> Procedure Test; far;
> Begin
> End;

In old freeware TP 5.5, that would be {$F+} at the top and {$F-} at
the bottom of the procedure. (I believe all procedures within the same
unit / file are near while external procedures are far by default.)

> Also, you may need assign the address to a plain pointer and typecast the 
> call.

Is that needed??

> Also, there are also compiler directives for FPC regarding compatibility.

Default dialect is "fpc", which is less strict than {$mode tp}, e.g.
it does change function pointer syntax a bit, but it also gives you
structured return types and function overloading.

{$asmmode intel} is only default for {$mode tp} as well (but you can
manually enable it, too).

Don't forget you can also declare inline functions! (Like real
inlining, not just inline machine code.)


___
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel


Re: [Freedos-devel] Problem with procedural types in 16-bit DOS FreePascal

2022-11-06 Thread Jerome Shidel
I’m not at my computer right now. So, this will just be rather vague….

Although I’ve used FPC/Lazarus for some things, I haven’t used it to create 
stuff to run under DOS. But, I have seen some weirdness regarding this sort of 
thing when targeting current GUIs. I forget  the exact details. However, there 
a few things you might try if you have not already.

Make sure your compiling to the correct memory model. (I think huge, but you’ll 
need to double check that)

You may need to ensure the actual procedure is declared with far.

Procedure Test; far;
Begin
End;

Also, you may need assign the address to a plain pointer and typecast the call.

Type 
  MyProc = procedure;

Var
  P : pointer;

Begin
P := @Test;
MyProc(P^);
End.

Also, there are also compiler directives for FPC regarding compatibility. 

Jerome




___
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel