On 21/02/2015 12:59, IVP wrote: > Hi all, Hi joe, > Can I make PCLATH advance to 0x02 if (W + PCL) > FE > under any circumstances (ie wherever code happens to be) > > For example, if I execute > > movff pcl,temp0 ;eg PCL =3D 0xD8 > > addwf temp0 ;result of W * 8 > skpnc > incf pclath > > after the rlncf's, it seems to work. But seems a bit inelegant and > might not work as code is moved/edited the incf will works ever because the jump will stay in a 256 byte boundary. > I have plenty of code space and can org the mode routines to just > after a boundary so that they all have a common PCLATH but > that seems a bit crude. Or org the computed branch as a subroutine > after the main code (as you might for a table etc) rather than > embedding it in-line I left long ago the use of an ORG for this kind of things, I think that is = safer to do right calculation to maintain the code relocatable. The only problem will arise if you need also to check the 64kB boundary and= use PCLATU. I usually leave a comment to warning. I would change exactly like Christopher, with only one difference (find it!= ): movlw high(mode0) movwf pclath swap portc,w ;multiply * 16 rrncf wreg,w ;divide by 2 andlw 0x78 ;mask for 0x0f * 8 addlw low(mode0) ;calc dest address and store to W skpnc incf pclath,f ;remember PCLATU movwf pcl ;jump Nic --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .