[net.lang.pascal] Error in Turbo-Pascal?

vr0z05@unido.UUCP (04/04/85)

Hello folks,

is there anybody in net-land who is able to help me?
the following program will not work, but why not?
(TURBO-PASCAL V.2.0 on IBM-PC/XT)

>PROGRAM TEST;
>type REGPACK = record
>                  AX,BX,CX,DX,BP,SI,DI,DS,ES,FLAGS : integer;
>               end;
>var RECPACK : REGPACK;
>procedure INTR_TEST;
>begin
>   inline($FB/$CF) {STI/IRET}
>end;
>begin
>   RECPACK.AX := ($25 shl 8) + $50;
>   RECPACK.DS := cseg;
>   RECPACK.DX := ofs(INTR_TEST);
>   intr($21,RECPACK);
>   intr($50,RECPACK);
>end.

The program starts correct, changes the interrupt-vector $50 to the address
of INTR_TEST, then calls via INT the procedure INTR_TEST and executes it
(until now nothing wrong), but after that the program hangs (no BREAK,
no RESET will work, only POWER OFF/ON).

Helpfull hints to

Uwe Hoch
University of Dortmund
Computer Science Department(IRB)
P.O. Box 500500
D-4600 Dortmund 50
West-Germany

via mail or uucp.

Thanks in advance!

jph@whuxlm.UUCP (Holtman Jim) (04/05/85)

> 
> Hello folks,
> 
> is there anybody in net-land who is able to help me?
> the following program will not work, but why not?
> (TURBO-PASCAL V.2.0 on IBM-PC/XT)
> 
> >PROGRAM TEST;
> >type REGPACK = record
> >                  AX,BX,CX,DX,BP,SI,DI,DS,ES,FLAGS : integer;
> >               end;
> >var RECPACK : REGPACK;
> >procedure INTR_TEST;
> >begin
> >   inline($FB/$CF) {STI/IRET}
> >end;
> >begin
> >   RECPACK.AX := ($25 shl 8) + $50;
> >   RECPACK.DS := cseg;
> >   RECPACK.DX := ofs(INTR_TEST);
> >   intr($21,RECPACK);
> >   intr($50,RECPACK);
> >end.
> 
> The program starts correct, changes the interrupt-vector $50 to the address
> of INTR_TEST, then calls via INT the procedure INTR_TEST and executes it
> (until now nothing wrong), but after that the program hangs (no BREAK,
> no RESET will work, only POWER OFF/ON).
> 
> Helpfull hints to
> 
> Uwe Hoch
> University of Dortmund
> Computer Science Department(IRB)
> P.O. Box 500500
> D-4600 Dortmund 50
> West-Germany
> 
> via mail or uucp.
> 
> Thanks in advance!

The problem is not in TURBO, it is in you INLINE statement. If you
take a look at the code that is generated at INTR_TEST, you will
see the following:

	PUSH	BP
	MOV	BP,SP
	PUSH	BP
	JMP	L1
L1:	STI		; STATMENTS FROM inline
	IRET

What you have to do is to modify your INLINE to include the POPs
of 2 BPs; e.g.

     inline($FB/$5D/$5D/$CF)

which will generate the following:

	PUSH	BP
	MOV	BP,SP
	PUSH	BP
	JMP	L1
L1:	STI		; STATMENTS FROM inline
	POP	BP
	POP	BP
	IRET