[comp.sys.atari.st] Bus errors

apratt@atari.UUCP (Allan Pratt) (04/11/90)

achowe@tiger.waterloo.edu (anthony howe) writes:
>Is a bus error generated if a memory reference is made to memory
>outside the range specified in system variables [_memlow, _memtop] or 
>on the range [0, phystop]?

You shouldn't rely on getting a bus error (or not getting one) anywhere.
People can muck with the variables you mention, so you really can't
count on them.

This is a good time to publish my universal bus-error code fragment. It
works on any CPU and it doesn't even have to check what CPU it's on. Of
course, it must run in Supervisor mode, because it fools with the bus
error vector.  The key to the code is that it cleans off the bus error
exception from the stack regardless of how much the CPU put there.  It
does this by saving the original SSP and restoring it later, rather
than adding a constant number of bytes to SSP. (If you DON'T get a bus
error, the final "move a1,sp" is a no-op.)

begin:
	move.l	$8,a0
	move.l	sp,a1
	move.l	#berr,$8

* Do something that might cause bus error
	move.l	testaddr,d0

* If you get to the next instruction, you DIDN'T get a bus error.
* Handle that case here (zero a flag), then branch to berrdone.

	sf	berrflag
	bra	berrdone

* If you get to this label, you DID get a bus error.  Handle that
* case (set a flag), then fall through to berrdone.

berr:	st	berrflag

berrdone:
	move.l	a0,$8
	move.l	a1,sp

============================================
Opinions expressed above do not necessarily	-- Allan Pratt, Atari Corp.
reflect those of Atari Corp. or anyone else.	  ...ames!atari!apratt