> > > ; The macro senses if there is need to set PCLATH. > > > ; If setting PCLATH (corrupt W) it saves and restores W in Wtemp if > > Wtemp<>0. > > > ; So we have fully automatic code optimization! > > > CALLPAGE macro target,Wtemp > > > if high target == high $ ;No need to change PCLATH > > > messg "CALLPAGE evaluated to simple call" > > > else > > > if Wtemp == 0 ;Do not save and reload W, +2 > instructions > > > movlw high target > > > movwf PCLATH > > > else ;Save and restore W using register adress Wtemp, > +4 > > instr. > > > movwf Wtemp > > > movlw high target > > > movwf PCLATH > > > movf Wtemp,W 1 data ram location used > > > endif > > > endif > > > call target > > > endm ; W PCLATH ; Wval ??? movwf PCLATH ; Wval Wval xorlw high target ;Wval XOR high target Wval xorwf PCLATH,f ;Wval XOR high target high target xorwf PCLATH,w ; Wval high target These 4 instructions made the same work but not use data ram. -- /* Alexandr Redchuk ReAl@real.kiev.ua */