> On Thu, Mar 10, 2011 at 11:04 AM, Olin Lathrop > wrote: >> Josh Koffman wrote: >>> For WREG, on entry I execute a >>> "MOVWF =A0 =A0 W_Temp", and on exit "MOVF =A0 =A0 W_Temp, W". >> >> That will trash some status bits. >> >> I don't get it. =A0Interrupt save/restore is a well-invented wheel= .. >> =A0Why >> do people keep trying to create their own code, especially when they >> don't >> know what they're doing enough to get it right!? > > Actually, I didn't invent it. It's come from numerous examples online > and in the datasheets. In this case, it's datasheet 39689f.pdf, page > 109, example 10-1. I didn't copy and paste the entire routing the > first time because I didn't think it was relevant. Evidently I was > incorrect. Here it is: > > Interrupt > movwf W_Temp ; Save context during low > interrupt > movff STATUS, STATUS_Temp > movff BSR, BSR_Temp > > > > movff BSR_Temp, BSR ; Restore context saved above > movf W_Temp, W > movff STATUS_Temp, STATUS > RETFIE > > > Josh > -- I was not in on the start of this thread, but we need to be careful as to which PIC family we're using. The fact that movff instructions were used tells me that this is a PIC18, since the PIC16 did not have these instructions. The PIC16 did not have the movff instruction, which does not affect status. So, the swap instruction was used instead, swapping status into a temp on the way in and swapping back on the way out. With the 18, though, this non-intuitive procedure was not required because we could use movff. It'd be great if the pic16 datasheet had described why a swap was being used. By the way, are there any comments on the datasheet section of the Microchip website? It seems useless to me. It shows everything but what I'm looking for. I now just use Google to find the datasheets. Harold --=20 FCC Rules Updated Daily at http://www.hallikainen.com - Advertising opportunities available! --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .