Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2021-04

Interruption handling on i8086

9 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Guillermo

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
to Guillermo

On Sat, Apr 10, 2021 at 10:14 AM Guillermo via fpc-pascal <

Show quoted text 16 lines
wrote: 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"

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
to Christo Crause: On Sat, Apr 10, 2021 at 10:14 AM Guillermo via fpc-pascal < This was fixed in trunk rev…
Show quoted text 24 lines
On Sat, Apr 10, 2021 at 10:14 AM Guillermo via fpc-pascal < > wrote: > 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" > 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

Guillermo
to Marco Borsari: Il 09/04/2021 19:56, Guillermo via fpc-pascal ha scritto: I have this handler from SWAG,…

El Sat, 10 Apr 2021 11:35:18 +0200

Marco Borsari wrote 8 lines
Il 09/04/2021 19:56, Guillermo via fpc-pascal ha scritto: > 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

Tomas Hajny

On 2021-04-09 19:56, Guillermo via fpc-pascal wrote:

Hi,

Show quoted text 11 lines
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"

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

Sven Barth
to Guillermo: El Sat, 10 Apr 2021 10:42:12 +0200 So it whould be fixed in 3.2.2. Maybe I should…
Guillermo wrote 27 lines
El Sat, 10 Apr 2021 10:42:12 +0200 Christo Crause escribió: > On Sat, Apr 10, 2021 at 10:14 AM Guillermo via fpc-pascal < > > wrote: > >> 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" >> > 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

Guillermo
to Tomas Hajny: I believe that you need to add the "far" modifier after the "interrupt" - at least this…

Hi, Tomas.

Show quoted text 11 lines
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.