[fpc-pascal]Modifying cpu registers while in turbo pascal interrupt routine ?

Nikolai Zhubr s001 at hotbox.ru
Fri Mar 19 22:59:57 CET 2004

Friday, 19 March, 2004, 14:10:02, Klaus Hartnegg wrote:
> No, programs compiled with Turbo-Pascal 7 with the $G+ option will
> use 32 bit registers for longint arithmetic if the program runs on a
> 386 cpu or higher. They test the cpu-type on startup and store the
Ok, I've found you are right essentially.
To be precise though, $G+ have no effect on this, as
TP7 compiler itself still generates pure 16-bit code.
Math libraries are most probably hand-made and use
32-bit code for intermediate calculations, depending
on test8086 variable value.
So, when going to use "interrupt" directive one should
do "test8086 := 1" before any interrupt ever happen.
Nice to learn this.
Best regards,
 Nikolai Zhubr
> result in the global variable 'test8086'. Longint library functions
> test this variable to decide which code to use.

> But the programs do not not save the upper half of the cpu-registers in 
> interrupt procedures, so if the interrupted main program is in the middle of a
> longint calculation and the interrupt procedure uses longint as well,
> then the calculation in the main programm can get incorrect results.

More information about the fpc-pascal mailing list