Interrupthandler in C

C and PASCAL (or any other high-level languages) in here please

Moderators: exxos, simonsunnyboy, Mug UK, Zorro 2, Moderator Team

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Interrupthandler in C

Postby Nyh » Fri Dec 11, 2009 12:59 am

From Professionals, Maximum depth of a file Path( http://www.atari-forum.com/viewtopic.php?f=27&t=18170)

DrCoolZic wrote:
Nyh wrote:
DrCoolZic wrote:I choose a prescale of 200 wich gives a period of about 81µs and an overflow every 20 ms. As I get back to the timer in less than 20 ms I can test for overflow and proceed accordingly, but it would probably be better to setup an interupt handler on overflow, but I do not know (yet) how to write that in C. :)

It is possible to do that in Pure C but this is dark magic. You can only use code that doesn't change registers.

Code: Select all

#include <stdio.h>
#include <tos.h>

void rte(void) 0x4E73;

volatile long int counter=0;

void handler(void)
{
  counter++;
  *(char*)0xfffa0fL=0xDF; /* clear interrupt mask */
  rte();
}

int main(void)
{
  Jdisint(13); /* disable timer A */
  Xbtimer(0, 1, 128, handler); /* install and enable timer A handler */
  for(;;)
  {
    printf("%li\n",counter);
  }
  return 0;
}


Hans Wessels

Yes this is really dark magic! and extremely elegant solution compared to the code I wrote manipulating the timer registers, going in/out of sv mode ... !!!!

Lets see if I can make sense out of this:

void rte(void) 0x4E73;
I remember that you already mentioned this capability of Pure C to drop "Assembly opcode" inside C code. I have been looking everywhere in the Pure C help files but could not find any information on this ?
How did you found about this feature? What is the syntax?

I think it was in the Borland Turbo C manual, and I suppose it is also in the Pure C manual but I have to check that out.
DrCoolZic wrote: If I remember correctly you also gave examples passing an argument. Something like func(long value) 0x???? In that case the code dropped would be ???? folowed by value ? Is it limited to Only one argument or more ? What type of argument char, short, long ... ? This looke extremely powerful and I am interested by information even if it is not really portable.

It is a normal function call, so parameters are passed like in a normal function call, first 3 integers in D0, D1 and D2, first 2 addresses in A0 and A1, rest on the stack. With the opcodes you can manipulate all registers any way you like. So:
long asm_add(long x, long y) 0xD081;
will add D1 to D0 and because Pure C expects the result of a function in D0 you get the right result.

This way of inserting instructions is nice to do simple things. Most often I used to control the interrupt priority level with a:
void move_sr(int value) 0x46c0; /* move D0,SR */
For complex things it is far easier to write an assembly subroutine.
DrCoolZic wrote:So with a name like rte I guessed that the 0x4E73 is instruction for return from exception (probably another name for interrupt in 68k terminology - sorry I am more an x86 guy :wink: )
By the way I have dowloaded lots of documents on motorola (user's guide, ... ) but none of them have a simple table that list by hex value the associated opcode? So I can easely find that $4e73 is an RTE operation ??? Any pointer to such document ?

Well, my 68000 reference manual has just such a table. The book is called:
"68000. Deel 1: Anatomie van een super-microprocessor" by L. Nachtmann, published by Elektuur, 1e druk, 1986
I am afraid it is in Dutch. I have heavily used the book and it contains a lot of notes. In the end, before the instruction time tables is a table from hex code to instruction.
DrCoolZic wrote:The rest of the code is relatively clear :? but I have few questions:
First: in the handler you access register directly and use RTE. All this needs to be done in SV mode, so my guess is that the handler declare in Xbtimer is called in SV mode (humm this sound pretty obvious) :wink:

Not quite. The handler routine is jumped to when a timer A interrupt occurs. Then the 68000 is in Super mode.
DrCoolZic wrote:Second: You used Jdisint() ? This is suppose to disable interrupt ? I was rather expecting Jenabint() function to be called ? so that timer can generate interrupt ?

I think it is a good coding practice to disable an interrupt before you are going to change it. I am not 100% sure whether Xbtimer() disables the interrupt too. Anyway, better safe than sorry. Xbtimer() installs and starts an interrupt routine so there is no need to enable it with Jenabint().
DrCoolZic wrote:I noted the usage of volatile, so that if counter is used in some other places in the code it does not get "optimized".

With the volatile declaration you tell the compiler it cannot optimize the variable into a register. Usually you do this for variables that are changed outside the normal program flow, ie by an interrupt routine or hardware registers.

Hans Wessels

User avatar
DrCoolZic
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2144
Joined: Mon Oct 03, 2005 7:03 pm
Location: France
Contact:

Re: Interrupthandler in C

Postby DrCoolZic » Fri Dec 11, 2009 9:58 am

Few precision about the code.

Code: Select all

 *(char*)0xfffa0fL=0xDF; /* clear interrupt mask */

This reset Timer A bit (5) in the interrupt in service register A. What is interesting is that this is obviously the correct address (I have it in some documentation), but this address is wrong in the atari compendium page 758 (B.38) !!! Here they indicate 0x00FFFA0E :(
The fact that you reset the Timer A IRS means that the 68901 is in SEI (soft. end of Int.) mode. Is this the defaut mode of operation of the 68901 (as opposed to the Automatic End of Int) ?

Code: Select all

  Xbtimer(0, 1, 128, handler); /* install and enable timer A handler */

second and third argument are control and data: so
control = 1 means timer A in delay mode (count down) XTAL divided by 4 => Period 1.6276 µs overflow 416.7 µs
data = 128 preset the counter to 128 but is really irrelevant.

About assembly inlining. I already noted few interesting one like: like the move_sr

Code: Select all

void move_sr(int value) 0x46c0; /* move D0,SR */
move_sr(0x2700);  /* disable all interrupt */
move_sr(0x2300);  /* enable all interrupts */

Do you have a version where you can save the current IPL state for something like:

Code: Select all

move sr, -(sp)
ori #$0700, sr
...
move (sp)+, sr


Any other good ones ???

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: Interrupthandler in C

Postby Nyh » Fri Dec 11, 2009 12:05 pm

DrCoolZic wrote:Few precision about the code.

Code: Select all

 *(char*)0xfffa0fL=0xDF; /* clear interrupt mask */

This reset Timer A bit (5) in the interrupt in service register A. What is interesting is that this is obviously the correct address (I have it in some documentation), but this address is wrong in the atari compendium page 758 (B.38) !!! Here they indicate 0x00FFFA0E :(

No, they indicate OB 0xFFFA0E. OB = Occupies the odd BYTE of a WORD.

DrCoolZic wrote:The fact that you reset the Timer A IRS means that the 68901 is in SEI (soft. end of Int.) mode. Is this the defaut mode of operation of the 68901 (as opposed to the Automatic End of Int) ?

Yes, that is the save way to do it. Otherwise you my get a new interrupt call when you are still working on the previous one.
DrCoolZic wrote:

Code: Select all

  Xbtimer(0, 1, 128, handler); /* install and enable timer A handler */

second and third argument are control and data: so
control = 1 means timer A in delay mode (count down) XTAL divided by 4 => Period 1.6276 µs overflow 416.7 µs
data = 128 preset the counter to 128 but is really irrelevant.

The MFP clock is divided by 4 and after 128 of those divided clock ticks you get a timer interrupt. The counter runs then with 2.4576/4/128=4800 Hz. So the 128 is really very relevant.

DrCoolZic wrote:About assembly inlining. I already noted few interesting one like: like the move_sr
Do you have a version where you can save the current IPL state for something like:

Code: Select all

move sr, -(sp)
ori #$0700, sr
...
move (sp)+, sr

Any other good ones ???

Moving things to the stack is not a good idea because the compiler might store values on the stack. It is far better to make a symmetrical set of instructions to handle the SR:

Code: Select all

void set_sr(int value) 0x46C0; /* write value into the SR */
int get_sr(void) 0x40C0; /* returns the current value of the SR */

With the value of the SR as a function result you can do anything you desire with it. No need for additional SR instructions.

Hans Wessels

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: Interrupthandler in C

Postby Nyh » Fri Dec 11, 2009 12:18 pm

Warning, compiler bug in Pure C 1.1

While writing some code it noticed a compiler bug in Pure C:

Volatile doesn't work as it should!

I wrote this code:

Code: Select all

volatile long timer
{
  long t0=timer;
  long t1=timer;
}

This should compile as:

Code: Select all

move.l timer,D0
move.l timer,D1

But Pure C compiles it as:

Code: Select all

move.l timer,D0
move.l D0,D1

Which is wrong, the volatile modifier is ignored.

Hans Wessels

User avatar
DrCoolZic
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2144
Joined: Mon Oct 03, 2005 7:03 pm
Location: France
Contact:

Re: Interrupthandler in C

Postby DrCoolZic » Fri Dec 11, 2009 12:53 pm

Nyh wrote:Warning, compiler bug in Pure C 1.1

While writing some code it noticed a compiler bug in Pure C:

Volatile doesn't work as it should!

I wrote this code:

Code: Select all

volatile long timer
{
  long t0=timer;
  long t1=timer;
}

This should compile as:

Code: Select all

move.l timer,D0
move.l timer,D1

But Pure C compiles it as:

Code: Select all

move.l timer,D0
move.l D0,D1

Which is wrong, the volatile modifier is ignored.

Hans Wessels

Yes it looks like both Pure C and Lattice do not handle volatile as expected. If you remember we already discussed about this subject in 2007 here http://www.atari-forum.com/viewtopic.php?f=16&t=9128&hilit=volatile&start=60&p=84482#p84482

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: Interrupthandler in C

Postby Nyh » Fri Dec 11, 2009 1:01 pm

DrCoolZic wrote:Yes it looks like both Pure C and Lattice do not handle volatile as expected. If you remember we already discussed about this subject in 2007 here http://www.atari-forum.com/viewtopic.php?f=16&t=9128&hilit=volatile&start=60&p=84482#p84482

Indeed. I forgot about this.

Hans Wessels

User avatar
DrCoolZic
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2144
Joined: Mon Oct 03, 2005 7:03 pm
Location: France
Contact:

Re: Interrupthandler in C

Postby DrCoolZic » Fri Dec 11, 2009 1:16 pm

Nyh wrote:
DrCoolZic wrote:

Code: Select all

  Xbtimer(0, 1, 128, handler); /* install and enable timer A handler */

second and third argument are control and data: so
control = 1 means timer A in delay mode (count down) XTAL divided by 4 => Period 1.6276 µs overflow 416.7 µs
data = 128 preset the counter to 128 but is really irrelevant.

The MFP clock is divided by 4 and after 128 of those divided clock ticks you get a timer interrupt. The counter runs then with 2.4576/4/128=4800 Hz. So the 128 is really very relevant.

Yes your are perfectly right. I usually loads the datareg to 0 to get an overflow every 256 clocks. Therefore I got confused that once reached 0 the timer would continue decrementing. But in general this is of course this is wrong. As you mention when the timer reach 0 it is reloaded with the value in the data register.
The value that I gave (Period 1.6276 µs overflow 416.7 µs) were for datareg = 0

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: Interrupthandler in C

Postby Nyh » Fri Dec 11, 2009 1:19 pm

DrCoolZic wants a precision timer in C. I just casted some extra dark magic C spells with some nice results. :-)
With the get_precision_timer() function you access a 614400 kHz timer (a bit more as 13 CPU cycles per timer tick), the overhead reading the timer is about 4 timer ticks. But it is all written in C. You can modify the timer speed by changing the Timer A prescaler.

Code: Select all

#include <stdio.h>
#include <tos.h>

void rte(void) 0x4E73;
unsigned long get_precision_timer(void) 0x4E43;

volatile unsigned long counter=0;

void handler(void)
{
  counter++;
  *(char*)0xfffa0fL=0xDF;
  rte();
}

unsigned long calc_time(void)
{
  unsigned long* counterp=&counter;
  unsigned long t0=*counterp;
  unsigned char ta=*(unsigned char*)0xFFFA1FL;
  unsigned long t1=*counterp;
  ta--;
  if((t0!=t1) && (ta>127))
  {
    t0=t1;
  }
  return (t0<<8)+(0xFF-ta);
}

void timer_handler(void)
{
  calc_time();
  rte();
}

void install_timer_handler(void)
{
  *(long *)0x8C=(long*)timer_handler;
}

int main(void)
{
  Supexec((long)(install_timer_handler));
  Jdisint(13); /* disable timer A */
  Xbtimer(0, 1, 0, handler); /* install and enable timer A handler */
  for(;;)
  {
    long t0=get_precision_timer();
    long t1=get_precision_timer();
    long t2=get_precision_timer();
    long t3=get_precision_timer();
    long t4=get_precision_timer();
    long t5=get_precision_timer();
    long t6=get_precision_timer();
    long t7=get_precision_timer();
    long t8=get_precision_timer();
    long t9=get_precision_timer();
    printf("%li %li %li %li %li %li %li %li %li %li\n", t0, t1, t2, t3, t4, t5, t6, t7, t8, t9);
  }
  return 0;
}

Disabling timers and cleaning the mess up after use is left as an exercise to the reader.

The timer_handler() is called be the get_precision_timer() function. Some trickery with function results to keep D0 alive and keep the compiler happy. timer_handler() is not defined as a function with an result be in real life wit will return the long in D0 which is the result of get_precision_timer(). This value is calculated by calc_time().

In the timer_handler() we can not use registers other then D0-D2,A0,A1 because we are returning with an RTE before the compiler cleans the stack. So timer_handler() calls an other function. In this function we have full access to all registers because the compiler can clean up the stack when it is done.

Hans Wessels

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: Interrupthandler in C

Postby Nyh » Fri Dec 11, 2009 3:07 pm

I wrote the timer_handler() function in assembly. I think it is a bit faster: :-)

Code: Select all

timer_handler:
     lea     counter(pc),a0
     moveq   #0,d1
     move.l  (a0),d0
     sub.b   $fffa1f,d1
     bmi.s   .done
     move.l  (a0),d0
.done:
     lsl.l   #8,d0
     move.b  d1,d0
     rte

Some of the tricks can be ported to C but not all.

Hans Wessels

User avatar
DrCoolZic
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2144
Joined: Mon Oct 03, 2005 7:03 pm
Location: France
Contact:

Re: Interrupthandler in C

Postby DrCoolZic » Sat Dec 12, 2009 9:24 am

Nyh wrote:

Code: Select all

  Jdisint(13); /* disable timer A */
  Xbtimer(0, 1, 128, handler); /* install and enable timer A handler */


During development I have splashed some code for the timer inside a loop. :(

Code: Select all

while ( ... ) {
  Jdisint(13); /* disable timer A */
  Xbtimer(0, 2, 246, handler); /* start timer A - tick about 1 msec. */
   ...
     measure timing info ...
   ...
   Xbtimer(0, 0, 0, handler); /* stop timer A */
  Jdisint(13); /* disable timer A */
}

Of course this is a stupid way to use the code (now fixed) but this resulted in a system crash (with over 20 bombs) that I can't understand?
This happen after a relatively long period of time and sounds like a "running out of some ressource" somewhere ...
I have now fixed the code so that the start/stop is out of the loop and it works fine but would be interested to know why this was causing a crash?

Side question: I am using recursive call to traverse the folders tree and stack size might get a problem (most likely not - as tree are not that deep). How do you approximate stack size and how do you specify that. I know I am lazy I can probably find this in the doc :wink:

And by the way your last solution is very nice (may a bit overkilling for what I need).
I would not call your code "dark magic" but rather "white magic" and your definitively an Elf (elegant and efficient) of the sw development ! But after all Magic is Magic :mrgreen:

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2058
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: Interrupthandler in C

Postby charles » Sat Dec 12, 2009 2:52 pm

i've got a code some where that makes use of this ,

i was asking awhile back for the similar thing in pascal or gfa ..
because i can't understand 'c'

i'll post it here once i find it .

then maybe we can sort this out and get a perfect example for all to use.



charles

ok edit**

Code: Select all


 The Pro MIDI Player
 Copyright 1986-1994 By J.D. Koftinoff Software, Ltd.
 Released under the GPL in 2007
 Please see the file 'COPYING' including in this package.
 
*/
 
/*   clocks.c
**
**   Handles all Xbtimer clock calls.
**  has the ability to set Xbtimer to whatever frequency
**  you want.
**
**   there is more accuracy for lower frequencies.
**
**   frequency range: 48 Hz to 614400 Hz.
**
**   call set_timer( long frequency ) to start the clocks
**   call unset_timer() to stop.
**
**   you can access and reset the clock by directly accessing
**      clock_ticks (long)
*/

#include <jk_sys.h>
#include <osbind.h>
#include <clocks.h>

#define SEND_INT_CLOCK 1

extern "C" void my_interrupt( void );


long clock_ticks;

#if SEND_INT_CLOCK
short clock_ticks_per_midi_clock=4;
short cur_midi_clock_tick_count=4;
#endif


asm( "
   
   MFP       =(0xfffffa00)
   S6850      =(0xfffffc00)
   MFP_CLOCK   =(2457600)


   Mgpip       =(MFP+1)
   Maer      =(MFP+3)
   Mddr      =(MFP+5)
   
   Miera      =(MFP+7)
   Mierb      =(MFP+9)
   Mipra      =(MFP+0xb)
   Miprb      =(MFP+0xd)
   Misra      =(MFP+0xf)
   Misrb      =(MFP+0x11)
   Mimra      =(MFP+0x13)
   Mimrb      =(MFP+0x15)
   Mvr      =(MFP+0x17)
   
   Mtacr      =(MFP+0x19)
   Mtbcr      =(MFP+0x1b)
   Mtcdcr       =(MFP+0x1d)
   Mtadr      =(MFP+0x1f)
   Mtbdr      =(MFP+0x21)
   Mtcdr      =(MFP+0x23)
   Mtddr      =(MFP+0x25)
   
   
   Mscr      =(MFP+0x27)
   Mucr      =(MFP+0x29)
   Mrsr      =(MFP+0x2b)
   Mtsr      =(MFP+0x2d)
   Mudr      =(MFP+0x2f)
   
   
   Skeyctl      =(S6850)
   Skeybd      =(S6850+2)
   Smidictl   =(S6850+4)
   Smidi      =(S6850+6)


   IBit0      =0x100
   IBit1      =0x104
   IBit2      =0x108
   IBit3      =0x10c
   ITimerD      =0x110
   ITimerC      =0x114
   IBit4      =0x118
   IBit5      =0x11c
   ITimerB      =0x120
   ITxERR      =0x124
   ITxDATA      =0x128
   IRxERR      =0x12c
   IRxDATA      =0x130
   ITimerA      =0x134
   IBit6      =0x138
   IBit7      =0x13c
" );

#if SEND_INT_CLOCK
asm ("
_my_interrupt:
      movl   d0,sp@-
      addql   #1,_clock_ticks
      subqw   #1,_cur_midi_clock_tick_count

      jne   _my_interrupt_end
      
      movw   _clock_ticks_per_midi_clock,_cur_midi_clock_tick_count

_my_interrupt_loop:
      movb   Smidictl,d0
      btst   #1,d0
      jeq   _my_interrupt_loop
      
      movb   #0xf8,Smidi

_my_interrupt_end:   
      movl   sp@+,d0
      bclr   #5,0xfffa0f
         /* Tell MFP the interrupt has been serviced   */
      rte
");
#else
asm ("
_my_interrupt:
      addql   #1,_clock_ticks

      bclr   #5,0xfffa0f
         /* Tell MFP the interrupt has been serviced   */
      rte
");
#endif



void set_timer( long freq)
{
int cntrl, count;
static int prescales[]= {
   0, 4, 10, 16, 50, 64, 100, 200
};

   cntrl=0;
   
   if( freq<=614400 && freq>=2400 ) {
      cntrl=1;   /* divide by 4     */
      goto done;
   }
   if( freq<2400 && freq>=960 ) {
      cntrl=2;      /* divide by 10    */
      goto done;
   }
   if( freq<960  && freq>=600 ) {
      cntrl=3;      /* divide by 16    */
      goto done;
   }
   if( freq<600  && freq>=192 ) {
      cntrl=4;      /* divide by 50    */
      goto done;
   }
   if( freq<192  && freq>=150 ) {
      cntrl=5;      /* divide by 64    */
      goto done;
   }
   if( freq<150  && freq>=96  ) {
      cntrl=6;      /* divide by 100   */
      goto done;
   }
      
   if( freq<96   && freq>=48  ) {
      cntrl=7;       /* divide by 200   */
      goto done;
   }
   
   if( cntrl==0 ) {
      return;
   }
   
done:
   /* entire range is not checked above; this is because if we
   ** use (for example) divide by 50 instead of divide by 100
   ** for the same frequency, our calculated count value will be
   ** larger, giving us a more accurate clock
   */
   
   count=2457600/(prescales[cntrl]*freq);

   Xbtimer(0, cntrl, count, my_interrupt );
}


void unset_timer()
{
   Xbtimer(0, 0, 0, NULL);
}

static short midi_byte;

static void _clock_midi_out()
{
   asm( "
      movw   sr,sp@-
      orw   #0x700,sr
_amy_loop:
      movb   Smidictl,d0
      btst   #1,d0
      jeq   _amy_loop
      
      movw   _midi_byte,d0
      movb   d0,Smidi
      movw   sp@+,sr
   " );
}

void clock_midi_out( short a )
{
   midi_byte=a;
   Supexec( _clock_midi_out );
}


 
You do not have the required permissions to view the files attached to this post.
Last edited by charles on Sun Dec 13, 2009 10:10 pm, edited 1 time in total.
atari is my lifestyle,not a hobby.
HOLD ON ! ! !,
Im printing unreadable characters ...!

User avatar
Desty
Atari God
Atari God
Posts: 1951
Joined: Thu Apr 01, 2004 2:36 pm
Location: 53 21N 6 18W
Contact:

Re: Interrupthandler in C

Postby Desty » Sun Dec 13, 2009 9:49 pm

Preview button FTW :!:
tá'n poc ar buile!

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: Interrupthandler in C

Postby Nyh » Sat Dec 19, 2009 4:41 pm

DrCoolZic wrote:During development I have splashed some code for the timer inside a loop. :(

Code: Select all

while ( ... ) {
  Jdisint(13); /* disable timer A */
  Xbtimer(0, 2, 246, handler); /* start timer A - tick about 1 msec. */
   ...
     measure timing info ...
   ...
   Xbtimer(0, 0, 0, handler); /* stop timer A */
  Jdisint(13); /* disable timer A */
}

Of course this is a stupid way to use the code (now fixed) but this resulted in a system crash (with over 20 bombs) that I can't understand?
This happen after a relatively long period of time and sounds like a "running out of some ressource" somewhere ...

My guess is you had a spurious interrupt. I think you should use Jdisint() before you use Xbtimer(). But I am only guessing here. Best way to find out is to run the program under the debugger.

Hans Wessels

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: Interrupthandler in C

Postby Nyh » Sat Dec 19, 2009 4:51 pm

charles wrote:i've got a code some where that makes use of this ,

i was asking awhile back for the similar thing in pascal or gfa ..
because i can't understand 'c'

i'll post it here once i find it .

then maybe we can sort this out and get a perfect example for all to use.

There is not much C specific code in the code you posted. Most of it is assembly. You posted the core of a MIDI replay routine in assembly.

This thread is not about creating the perfect code for all to use. But about the perfect example for all to understand.

After you understand you can write the perfect code for yourself to use.

Hans Wessels

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2058
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: Interrupthandler in C

Postby charles » Sat Dec 19, 2009 8:39 pm

is this interupt handler done while in supervisor mode>?

from what i remeber anything with peeking at the timer can be done without supervisor mode

but
installing new values to the timer needs done in supervisor mode.


probally not appicable right now as this applies to my code and not yours


any how
theres more examples in the folder , have fun "cookie cutting" up some code

charles
atari is my lifestyle,not a hobby.
HOLD ON ! ! !,
Im printing unreadable characters ...!

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: Interrupthandler in C

Postby Nyh » Sat Dec 19, 2009 10:33 pm

charles wrote:is this interupt handler done while in supervisor mode>?

from what i remeber anything with peeking at the timer can be done without supervisor mode

but
installing new values to the timer needs done in supervisor mode.

When you use the Xbios functions (Mfpint(), Jdisint(), Jenabint(), Xbtimer()) like I did you don't need to enter supervisor mode to install a timer interrupt handler or to set new values in the timers. When you want to acces the MFP directly you need to be in super mode.

Hans Wessels

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2058
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: Interrupthandler in C

Postby charles » Sat Feb 27, 2010 1:09 am

hey did we get to understanding this xbtimer code much further?

i still can't see whats going on , with alot of the code i wrote pertaining to the xbtimer , it just freezes my timer c at 0 and does not escalate to much.

any input folk?

charles
atari is my lifestyle,not a hobby.
HOLD ON ! ! !,
Im printing unreadable characters ...!


Social Media

     

Return to “C / PASCAL etc.”

Who is online

Users browsing this forum: No registered users and 1 guest