Re: A83: Using the IY register


[Prev][Next][Index][Thread]

Re: A83: Using the IY register




In a message dated 14/03/00 10:47:42 GMT Standard Time, jimbob_v@hotmail.com 
writes:

Yep, thats correct. If you change IY you can cause chaos if interrupts are 
still
enabled. I begin to wonder if the best approach is to ignore *all* the TI 
code :)

Rather than use DI and EI directly, you may be better off using a nested
interrupt disable. This allows you to have routines using IY nested within
routines using IY.

Example (in 'C' but you get the point :))

static DICount = 0

void DI()
{
if (++DICount != 0) then di;
}

void EI()
{
if (--DICount == 0) then ei;
}


<< di                   ; Disable interrupts so IY can be used
 push iy              ; Preserve IY (pointer to system flags)
 {code}
 pop iy
 ei
 
   The "di" and "ei" are required.. correct? I think so, cos not having them 
 caused one of bugs in my game I think... >>