[comp.sys.atari.st] How to call the bios ...

roeder@sbsvax.UUCP (Edgar Roeder) (01/13/90)

In article <1937@atari.UUCP>, apratt@atari.UUCP (Allan Pratt) writes:
> I think it's a reentrancy problem.  The OS hooks seem to use external
> storage, meaning they're non-reentrant.  Worse, they all use the SAME
> external location, so in a given program, you can't call BIOS from
> BIOS, but you also can't call XBIOS from BIOS! 
> [...]
> Hooks like this can be made reentrant by changing how they work:
> [example how to do it by copying the arguments]

There is another solution: use your own stack for saving the return address.
(This is also the method used in the ROM when bios is called.)

	move.l	stackpointer,a0
	move.l	(sp)+,-(a0)
	move.l	a0,stackpointer
	trap	#$x
	move.l	stackpointer,a0
	move.l	(a0)+,-(sp)
	move.l	a0,stackpointer
	rts

You have to initialize the variable stackpointer to point to the upper end of
some memory space reserved for this new stack. Although this does only allow
a limited level of reentrancy (the stack-space divided by the amount needed for
every call), you don't have to copy your arguments around.

	- Edgar
-- 

Mail:  Edgar R\"oder			E-Mail: roeder@cs.uni-sb.de
       Liesbet-Dill-Stra\ss e 3
D-6602 Dudweiler                               -o-   -o-
       W-Germany                                   ^
Phone: 06897/74643                     	       	 '---'