On Wed, Sep 17, 1997 at 04:19:31PM +0930, Mike Smith wrote: > On 16 Sep 97 at 21:56, Pioneer Microsystems wrote: > > into a windowed C554. All will fit properly, but I have a problem. > > This part has only one bank of user RAM. Upon interrupting, I might > > be in the upper page, and then my W save action will go zinging off > > How about > save RP0 to RP1 (which is unused, but available) The problem with this solution is that RP1 is marked by Microchip as not to be used - they advise that it should be left at zero. While in the chip itself RP1 does work, and has no bad side effects, if you run the MPLAB simulator for certain chips (not sure if it affects the '554, but it does affect the '62x chips) then setting RP1 does Bad Things. Specifically, all registers become inaccessible, including the STATUS register, so the only way to recover is to reset the simulator. Here's a better solution (or at least one sure to work): this code is what our compiler produces for the '554 interrupts (I've added comments): _isr btfsc 3,5 ;test if RP0 is set goto l30001 movwf saved_w ;if not, bank0 is selected, save w movf 3,w ;load status into w goto l30002 ;rejoin common code l30001 bcf 3,5 ;clear RP0 so we can movwf saved_w ; save W movf 3,w ;get STATUS (with cleared RP0) iorlw 32 ;re-set RP0 in the saved copy l30002 movwf saved_status ;store saved status in memory ;x.c: 6: i++; ; here's your real work incf (_i& (0+127))& (0+127) btfsc 3,2 incf ((_i+1)& (0+127))& (0+127) movf saved_status,w ;now recover saved status andlw 223 ;reset RP0 movwf 3 ;store into STATUS swapf saved_w ;restore W swapf saved_w,w ; using swapf's to preserve STATUS btfsc saved_status,5 ;now test the saved RP0 bsf 3,5 ;set the real RP0 if required retfie ;and continue our regular program... -- Clyde Smith-Stubbs | HI-TECH Software Email: clyde@htsoft.com | Phone Fax WWW: http://www.htsoft.com/ | USA: (408) 490 2885 (408) 490 2885 PGP: finger clyde@htsoft.com | AUS: +61 7 3354 2411 +61 7 3354 2422 --------------------------------------------------------------------------- ANSI C for the PIC! Now shipping! See www.htsoft.com for more info.