At 10:20 AM 6/19/02 -0700, Brendan Moran wrote: >I'm simulating something for the PIC16F877 with MPLAB SIM, and I'm getting >this wierd issue with PCLATH. > >I originally had an instruction operating on PCL and the address of the >instruction was 0xFF. That in itself caused problems, as PCLATH did not >change, so the code went back to 0 (I happened to be adding 0 to PCL in >that particular portion of the simulation). I found that problem, and >just moved the entire segment of code down 3 steps (just to be sure) with NOPs > >Now, when I do a goto 0x102, which should work, PCLATH does not update, >causing incorrect simulation, of course. PCLATH does NOT change by itself! *YOU* have to set it to point to the correct ROM segment. A very similar example was posted about a week ago. Here it is again: movwf SAVE_ADDR ; Save offset movlw high (table1) ;set the high bits of the table entry adr movwf pclath movlw low (table1) addwf SAVE_ADDR,W ; find appropriate offset skpnc ;wrap past end of current page? incf pclath,F ;yep - point to next page movwf PCL ;now go to correct entry in table table1 ;start address of the table retlw B'01111110' ; '0' retlw B'00110000' ; '1' . . . nop ; Error - '15' retlw B'00000001' ; Return dash dwayne -- Dwayne Reid Trinity Electronics Systems Ltd Edmonton, AB, CANADA (780) 489-3199 voice (780) 487-6397 fax Celebrating 18 years of Engineering Innovation (1984 - 2002) .-. .-. .-. .-. .-. .-. .-. .-. .-. .- `-' `-' `-' `-' `-' `-' `-' `-' `-' Do NOT send unsolicited commercial email to this email address. This message neither grants consent to receive unsolicited commercial email nor is intended to solicit commercial email. -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body