[comp.sys.atari.st] Help with timerA

tsakogia@uk.ac.man.cs (George Tsakogiannis) (05/01/91)

Newsgroups: comp.sys.atari.st.tech
Subject: Help with timerA
Distribution: comp.sys.atari.st.tech
--text follows this line--

This message is sent on behalf of Pakis Haliapas (haliapap@p4.cs.man.ac.uk):

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Does anybody out there know why when I compile the following program
(with HiSoft's GenST assembler) and run it on my STE the system crashes?

-------------------------
start
	bra	real_start
	even

TimerA_int
	rte
	even
     
real_start
	clr.l	-(sp)
	move.w	#$20,-(sp)
	trap	#1
	addq.l	#6,sp
	move.l	d0,old_sp
		
	move.l	#TimerA_int,$134
	move.b	#128,$FFFA1F
 	or.b	#$07,$FFFA19
	or.b	#$20,$FFFA07
	or.b	#$20,$FFFA13
	
	move.l	old_sp,-(sp)
	move.w	#$20,-(sp)
	trap	#1
	addq.l	#6,sp

loop1
	move.w	#2,-(sp)
	move.w	#1,-(sp)
	trap	#13
        addq.l	#4,sp
	cmp.w	#-1,d0
	bne	loop1
	
	move.w	#2,-(sp)
	move.w	#2,-(sp)
	trap	#13
	addq.l	#4,sp
	
	clr.w	-(sp)
	trap	#1


cl_counter	dc.l	0
old_sp		dc.l	0
-------------------------

The following program does exactly the same thing too:

-------------------------
start
	bra	real_start
	even

TimerA_int
	rte
	even
     
real_start
	move.l	#TimerA_int,-(sp)
	move.w	#128,-(sp)
	move.w	#7,-(sp)
	move.w	#0,-(sp)
	move.w	#31,-(sp)
	trap	#14
	add.l	#12,sp

loop1
	move.w	#2,-(sp)
	move.w	#1,-(sp)
	trap	#13
        addq.l	#4,sp
	cmp.w	#-1,d0
	bne	loop1
	
	move.w	#2,-(sp)
	move.w	#2,-(sp)
	trap	#13
	addq.l	#4,sp
	
	clr.w	-(sp)
	trap	#1


cl_counter	dc.l	0
old_sp		dc.l	0
-------------------------

Send any answers/comments/suggestions to 
haliapap@p4.cs.man.ac.uk
or to this net

Thank you in anticipation,
Pakis Haliapas,
Manchester.

warwick@cs.uq.oz.au (Warwick Allison) (05/03/91)

>Does anybody out there know why when I compile the following program
>(with HiSoft's GenST assembler) and run it on my STE the system crashes?

 :

>TimerA_int
>	rte
>	even

 :

It's a long time since I encapsulated TimerA use in a module :-), but I
think you need to clear an interrupt-pending bit on the before you return
from the exception.

Check out what TimerB, C and D do, check Internals (though from memory
there was a bug in that part :-( ), or grab play.arc from atari.archive
and look for the interrupt code that writes to the Yamaha chip.

You're an assembler programmer - you'll enjoy it. :-)

If you get stuck, mail back, and I'll check my modules (at home).  It isn't
very difficult, just tedious to hold your tongue in just the right way.

Warwick.
PS. As I said, it's been a while - I may be completely off track.
--
  _-_|\       warwick@cs.uq.oz.au
 /     *  <-- Computer Science Department,
 \_.-._/      University of Queensland,
      v       Brisbane, AUSTRALIA.