Page 1 of 2

Bus error handling problem

Posted: 17 May 2022 21:34
by exxos
I honestly cannot remember who wrote this routine...

Code: Select all

*-----------------------------------------------------------------------------*
EXXOS_BusErrorTest:
*-----------------------------------------------------------------------------*
	move.l 		bas_params(pc),a0		; a0 = basic variable ptr
	move.l		(a0),a1				; a1 = basic variable (address to test)
	move.l		sp,d2				; d2 = old stack pointer
	move.l		$8,d1				; d1 = old berr handler

	move.w		#.berr-EXXOS_BusErrorTest,d3	; d3 = err handler offset
	lea		EXXOS_BusErrorTest(pc,d3.w),a2	; a2 = err handler absolute address
	move.l		a2,$8				; set new berr handler

	move.l		(a1),d0				; read from address
	move.l		d1,$8				; restore berr handler
	move.l		#1,(a0)				; return 1
	rts
.berr:
	move.l		d2,sp				; restore stack to before berr
	move.l		d1,$8				; restore berr handler
	move.l		#0,(a0)				; return 0
	rts
Maybe someone have some ideas as to what is going on with it. IIRC was working when I would test a RAM location, basically because that location is used to returned a value back to BASIC code.

So I did a test routine where I could return to separate values by doing this..

Code: Select all

	move.l 		bas_params(pc),a0		; a0 = basic variable ptr    6 ?
	move.l		(a0),a1				; a1 = basic variable (address to test) FF8964   
 	move.l		#1234,(a0)			; return 1234 in X&
	move.l		#5678,4(a0)			; return 5678 in Y&
	rts
And this correctly returns the value to BASIC.

Capture.PNG


So I make the assumption that return 1 and return 0 get changed from #0,(a0) TO #0,4(a0) as that is what worked in my test routine.

However something has broken in the bus error handler and I have no idea what. I thought it was down to those code changes but even if I comments them out the handler crashes :(

If I simply put a RTS the start of the code then things don't crash. So definitely wrong with that bus error handler routine somehow :shrug:

Re: Bus error handling problem

Posted: 17 May 2022 22:00
by exxos
When I call the routine I have been passing the actual address as a parameter EG:

Code: Select all

 t&=&HFF8964 
  Y&=66666
 call loc testcode&,EXXOS_BusErrorTest,t& ,varptr(Y&)
Which bomns out.


But passing the RAM pointer to the variable doesn't crash, but it returns 0 regardless of it the address is valid or not.

Code: Select all

 t&=&HFF8964 
  Y&=66666
 call loc testcode&,EXXOS_BusErrorTest,varptr(t&) ,varptr(Y&)

EDIT:

Must be something else broken somewhere as if I copy the working code into the BUSERROR routine and just RTS early, it doesn't return #1234 :WTF:

Re: Bus error handling problem

Posted: 17 May 2022 22:48
by exxos
FFS!

I used t& as a variable and it NEVER returned a value. I changed it to X& and now its starting to behave.. and t& isn't even used anywhere in the program :WTF: Feking bonkers faults again :pullhair: :headbang:

Re: Bus error handling problem

Posted: 17 May 2022 23:01
by mrbombermillzy
Are we good now then?

Re: Bus error handling problem

Posted: 17 May 2022 23:02
by exxos
Sooo..

STEEM - no Flashyclock

1.PNG


Real hardware with FC

IMG_0588.JPG

So no feking idea why hisoft basic didn't like that variable name. I hate computers!

:comp:


and proof..

Capture.PNG

It's not just because its lower case either. Only possible thing is if t& is some internal thing :shrug: eitherway, waste 2 days just working that out :roll: :headbang:

Re: Bus error handling problem

Posted: 17 May 2022 23:11
by Badwolf
Glad you've got it sorted out.

Since you're doubtlessly feeling completely better and not at all sore about it any more, can we now go back to taking the Gipsy Kiss out of you for using a Noddy language?

Too soon..?

;)

BW

Re: Bus error handling problem

Posted: 17 May 2022 23:29
by exxos
Badwolf wrote: 17 May 2022 23:11 Since you're doubtlessly feeling completely better and not at all sore about it any more, can we now go back to taking the Gipsy Kiss out of you for using a Noddy language?
:chairsmack:


It's always me which finds bonkers bugs in stuff regardless of what I use :roll: It's not like I even code much of anything :roll:

Re: Bus error handling problem

Posted: 19 May 2022 16:33
by exxos
There is still something odd going on :roll:

Would this code work for WORD or BYTE access ? I can peek a byte or word in STOS and I get a number back, but a LONG I get BERR. Fair enough. But this code looks like it deals with longs ? So would that screw up WORD access checks ?!

Code: Select all

	move.l 		bas_params(pc),a0		; a0 = basic variable ptr    6 ?
	move.l		(a0),a1				; a1 = basic variable (address to test) FF8964 
  
	move.l		sp,d2				; d2 = old stack pointer
	move.l		$8,d1				; d1 = old berr handler

	move.w		#.berr-EXXOS_BusErrorTest,d3	; d3 = err handler offset
	lea		EXXOS_BusErrorTest(pc,d3.w),a2	; a2 = err handler absolute address
	move.l		a2,$8				; set new berr handler

	move.l		(a1),d0				; read from address
	move.l		d1,$8				; restore berr handler

	move.l		#1,4(a0)				; return 1
	rts
.berr:
	move.l		d2,sp				; restore stack to before berr
	move.l		d1,$8				; restore berr handler

	move.l		#0,4(a0)				; return 0
	rts

Re: Bus error handling problem

Posted: 19 May 2022 16:39
by exxos
OK so doing

Code: Select all

move.w		(a1),d0	
Seems to work now..

Re: Bus error handling problem

Posted: 19 May 2022 17:29
by sporniket
It looks like accessing a1+2 does trigger the error handler then ?