Discussion:
[fpc-pascal] Interruption handling on i8086
Guillermo via fpc-pascal
2021-04-09 17:56:12 UTC
Permalink
Hi pascaloids,

I'm doing DOS development for fun and, after installing the compiler
(was quite hard), I'm having problems handling interrupts.

I started with keyboard and it doesn't work. The handler declaration:

procedure DOS_KbdHandler; interrupt;

but compiler says:

keybrd.inc(14,29) Warning: Calling convention directive ignored:
"OldFPCCall"

When running the program in DOSBox it just executes the interruption
once when I press any key and then the interruption doesn't executes
anymore. I thought the compiler doesn't manage the interruption
enter/exit stuff properly (since it says the calling convention was
ignored) so I tried to add the "CLI" and "STI IRET" by myself, but the
compiler sayd:

keybrd.inc(21,7) Error: Instruction not supported by the selected
instruction set

The instruction not supported is IRET.

BTW, I tried the same thing for DOS 32bits (with all the GO32V2 stuff)
and it worked as expected. I've attached both 16bits and 32bits code,
complete with initialization, handling and finalization.

Do anybody see what I'm doing wrong? How can I fix it?

Guillermo "Ñuño" Martínez
Christo Crause via fpc-pascal
2021-04-10 08:42:12 UTC
Permalink
On Sat, Apr 10, 2021 at 10:14 AM Guillermo via fpc-pascal <
Post by Guillermo via fpc-pascal
Hi pascaloids,
I'm doing DOS development for fun and, after installing the compiler
(was quite hard), I'm having problems handling interrupts.
procedure DOS_KbdHandler; interrupt;
"OldFPCCall"
This was fixed in trunk rev 39838 (
https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/compiler/pdecsub.pas?r1=39703&r2=39838),
but so far the fix didn't make it into a release yet. At least for AVR the
warning can be ignored. Not sure why your code doesn't work properly on
i8086 though.
Guillermo via fpc-pascal
2021-04-10 10:15:43 UTC
Permalink
El Sat, 10 Apr 2021 10:42:12 +0200
Post by Christo Crause via fpc-pascal
On Sat, Apr 10, 2021 at 10:14 AM Guillermo via fpc-pascal <
Post by Guillermo via fpc-pascal
Hi pascaloids,
I'm doing DOS development for fun and, after installing the compiler
(was quite hard), I'm having problems handling interrupts.
I started with keyboard and it doesn't work. The handler
procedure DOS_KbdHandler; interrupt;
"OldFPCCall"
This was fixed in trunk rev 39838 (
https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/compiler/pdecsub.pas?r1=39703&r2=39838),
but so far the fix didn't make it into a release yet. At least for
AVR the warning can be ignored. Not sure why your code doesn't work
properly on i8086 though.
So it whould be fixed in 3.2.2. Maybe I should install the RC and test
it.

Thanks for the note.

Guillermo "Ñuño" Martínez
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/list
Sven Barth via fpc-pascal
2021-04-10 22:26:39 UTC
Permalink
Post by Guillermo via fpc-pascal
El Sat, 10 Apr 2021 10:42:12 +0200
Post by Christo Crause via fpc-pascal
On Sat, Apr 10, 2021 at 10:14 AM Guillermo via fpc-pascal <
Post by Guillermo via fpc-pascal
Hi pascaloids,
I'm doing DOS development for fun and, after installing the compiler
(was quite hard), I'm having problems handling interrupts.
I started with keyboard and it doesn't work. The handler
procedure DOS_KbdHandler; interrupt;
"OldFPCCall"
This was fixed in trunk rev 39838 (
https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/compiler/pdecsub.pas?r1=39703&r2=39838),
but so far the fix didn't make it into a release yet. At least for
AVR the warning can be ignored. Not sure why your code doesn't work
properly on i8086 though.
So it whould be fixed in 3.2.2. Maybe I should install the RC and test
it.
That revision wasn't merged to 3.2.x, so it's not fixed in the RC. I've
now done so, thus it should be in the final 3.2.2.

Regards,
Sven
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pas
Guillermo via fpc-pascal
2021-04-11 10:03:32 UTC
Permalink
El Sun, 11 Apr 2021 00:26:39 +0200
Post by Sven Barth via fpc-pascal
That revision wasn't merged to 3.2.x, so it's not fixed in the RC.
I've now done so, thus it should be in the final 3.2.2.
Thanks Sven. I was about to ask at Lazarus forums right now. :)
Post by Sven Barth via fpc-pascal
Regards,
Sven
Regards,
Guillermo "Ñuño" Matínez

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://l

Marco Borsari via fpc-pascal
2021-04-10 09:35:18 UTC
Permalink
Post by Guillermo via fpc-pascal
Hi pascaloids,
I'm doing DOS development for fun and, after installing the compiler
(was quite hard), I'm having problems handling interrupts.
I have this handler from SWAG, hope it would be helpful.
Marco
Guillermo via fpc-pascal
2021-04-10 10:19:15 UTC
Permalink
El Sat, 10 Apr 2021 11:35:18 +0200
Post by Marco Borsari via fpc-pascal
Post by Guillermo via fpc-pascal
Hi pascaloids,
I'm doing DOS development for fun and, after installing the compiler
(was quite hard), I'm having problems handling interrupts.
I have this handler from SWAG, hope it would be helpful.
Marco
Thanks for the code snippet. It is quite similar to mine, but in
Assembler. I'll test it (specially the "{$F+}" thing that I didn't know
about).

Guillermo "Ñuño" Martínez
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-
Tomas Hajny via fpc-pascal
2021-04-10 14:05:28 UTC
Permalink
On 2021-04-09 19:56, Guillermo via fpc-pascal wrote:


Hi,
Post by Guillermo via fpc-pascal
I'm doing DOS development for fun and, after installing the compiler
(was quite hard), I'm having problems handling interrupts.
procedure DOS_KbdHandler; interrupt;
"OldFPCCall"
I believe that you need to add the "far" modifier after the "interrupt" - at least this has been the case with TP/BP and is probably needed at least for some memory models supported with FPC for i8086. The {$F+} directive as mentioned in your later post is an alternative, but not needed for the whole program (it might make it less efficient). I don't know if there are any other caveats.

Tomas

_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/lis
Guillermo via fpc-pascal
2021-04-11 09:57:57 UTC
Permalink
Hi, Tomas.

El Sat, 10 Apr 2021 16:05:28 +0200
Post by Tomas Hajny via fpc-pascal
Hi,
I believe that you need to add the "far" modifier after the
"interrupt" - at least this has been the case with TP/BP and is
probably needed at least for some memory models supported with FPC
for i8086. The {$F+} directive as mentioned in your later post is an
alternative, but not needed for the whole program (it might make it
less efficient). I don't know if there are any other caveats.
Tomas
It was long ago since I did my latest DOS 16bit program with Turbo
C/C++ 2.0 so I forgot the "far" modifier. Thank you to make me
remember it.

Now I remember I have to use it with Large and Huge, not sure about
Medium but I'll look for documentation. I'll also look for the {$F+}
directive to know how it behaves with Tiny and Compact models.


Regards,
Guillermo "Ñuño" Martínez.
_______________________________________________
fpc-pascal maillist - fpc-***@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/lis
Loading...