> At 21:58 24.03.97 -0600, you wrote: > >> > > Puzzle N2> Is required to load any file REGister with value = VALUE , > >> > > but W register haven't be changed after load is over . > >> > > >> > MOVWF reg > >> > XORLW VALUE > >> > XORWF reg,f > >> > XORWF reg,W > >> I've another similar solution... > >> > >> XORLW VALUE > >> MOVWF REG > >> XORLW VALUE > >> XORWF REG,F > > > >Depending upon /Value/, it may be possible to do the job in 1 to 5 cycles > >without altering W _or_ the flags (useful perhaps in an ISR, since saving > >context is such a pain). If the old value in the f-register is known, then > >any change may be done in 0 to 4 cycles (zero of course being if you want to > >"change" the register to its existing value). > > > >Here are some of the ways of setting a register in very few instructions: > > > >[1] Set to zero: the obvious one... > > clrf reg > > Doesn't CLRF alter the Z-flag?! I thought [perhaps I need to get out my book] that clrf only affected the Z flag on the 17Cxx parts. Hmm... I'll have to double-check that. > >[2] Set to a power of two. Also pretty obvious... > > clrf reg > > bsf reg,bit > > > >[3] Set to 255. Still pretty obvious, but for one slight detail... > > clrf reg > > decfsz reg ; Note: next instruction will NEVER be skipped. > > Don't we have SETF reg ? (Perhaps only 17Cxxx) Not on any of the 16Cxx devices. > regards, > > Wolfram Hmm... would be embarassing if I'm wrong on /clrf/.