Martin Kirk (mlk@ASU.EDU) wrote: >Will someone please give me a brief list of the requirements for clearing >the registers when moving one's code to non-windowed pics? I assume it >is a simple clear all registers operation. Please confirm. Martin: For the 16C54/55/56: PORTA EQU 004H MOVLW PORTA ;PREPARE TO ZERO ALL REGISTERS EXCEPT THE FSR, MOVWF FSR ;RTCC, PC, AND PROCESSOR STATUS REGISTERS. CLRRAM CLRF USEFSR ;ZERO A REGISTER. INCFSZ FSR ;HAVE WE DONE THEM ALL? GOTO CLRRAM ;IF NOT, LOOP BACK AND ZERO ANOTHER. For the 16C57/58: PORTA EQU 004H MOVLW PORTA ;PREPARE TO ZERO ALL REGISTERS EXCEPT THE MOVWF FSR ;PROCESSOR STATUS, PC, RTCC, AND FSR ;REGISTERS. CLRRAM MOVLW 00011111B ;ARE WE POINTING AT "USEFSR"? ANDWF FSR,W ; SKPNZ ;IF NOT, SKIP AHEAD. BSF FSR,BIT4 ;OTHERWISE, SKIP OVER THE PROCESSOR STATUS, ;PC, RTCC, FSR, PORTA, PORTB, PORTC, AND ;THE GLOBALLY-ACCESSIBLE FILE REGISTERS. CLRF USEFSR ;ZERO THE REGISTER AT WHICH WE'RE POINTING. INCFSZ FSR ;HAVE WE DONE THEM ALL? GOTO CLRRAM ;IF NOT, LOOP BACK AND ZERO ANOTHER. ; ALL FILE REGISTERS ARE ZEROED AND WE'RE IN DATA SEGMENT 0. For the 16C71: GPREGS EQU 00CH LASTGP EQU 02FH MOVLW GPREGS+1 ;CLEAR ALL GENERAL-PURPOSE REGISTERS. MOVWF FSR ;THIS ROUTINE WAS WRITTEN BY DON LEKEI. MOVLW LASTGP-GPREGS ; MOVWF GPREGS ; ; CLRRAM CLRF USEFSR ; ; INCF FSR ; DECFSZ GPREGS ; GOTO CLRRAM ; For the 16C74: FRSTGP0 EQU 020H LASTGP0 EQU 07FH MOVLW FRSTGP0 ;PREPARE TO ZERO ALL GENERAL-PURPOSE MOVWF FSR ;REGISTERS. CLRRAM MOVLW LASTGP0+1 ;ARE WE POINTING PAST THE FINAL PAGE-0 XORWF FSR,W ;REGISTER? SKPNZ ;IF NOT, SKIP AHEAD. BSF FSR,BIT5 ;OTHERWISE, ADJUST FSR TO SKIP OVER THE PAGE-1 ;SPECIAL-PURPOSE REGISTERS. CLRF USEFSR ;ZERO THE REGISTER AT WHICH WE'RE POINTING. INCFSZ FSR ;HAVE WE DONE THEM ALL? GOTO CLRRAM ;IF NOT, LOOP BACK AND ZERO ANOTHER. In addition to the equates shown in the above code fragments, you should be aware that "USEFSR" is my name for the indirect register (register number 0); some Microchip documentation now refers to this register as "INDF". "FSR", of course, should be equated to the appropriate register (this is left as an exercise for the reader). Enjoy... -Andy -- Andrew Warren - fastfwd@ix.netcom.com Fast Forward Engineering, Vista, California