----- Original Message ----- From: "Peter L. Peres" To: Sent: Monday, December 24, 2001 11:51 AM Subject: Re: [PIC]: Implementing MCLR in software > Hi Wouter, thanks for the ideas, are you trying to say that something like > this will work ?: > > main: > bsf STATUS,RP0 > clrf TRISA > bcf STATUS,RP0 > > call Thesub ; call it and then fall through into it > > Thesub: > movlw 0x01 > xorwf PORTA,f > retlw 0 ; this should jump to Thesub according to your > ; description (pop keeps popping the last value) > > BTW I bet a small sum of money that most simulators do not follow this > functionality. As to usefullness ? Every merchandise has its buyer [tm]. > > Peter > Peter, This sample will NOT work because only one entry on the stack has been initialized to contain the return address that gets you back to 'Thesub'. This ugly code would work however (assuming interrupts are off): main: bsf STATUS,RP0 clrf TRISA bcf STATUS,RP0 clrf COUNTER Docall: call Thesub Thesub: btfsc COUNTER,5 ; Have we already filled the stack? goto CountDone ; Yes incf COUNTER ; No, count one more goto Docall ; ...and push another level CountDone: movlw 1 xorwf PORTA,F retlw 0 ; will return to ''Thesub' forever incfsz COUNTER,F ; Bump the counter goto Docall ; D -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.