data_for_macro UDATA contatore res 2 ; Contatore utilizzato nel ciclo di ritardo WREG_TEMP res 1 ; Copia temporanea di WREG STATUS_TEMP res 1 ; Copia temporanea dei flags di stato BSR_TEMP res 1 ; Copia temporanea di BSR ; Ciclo di ritardo - 100 ms (circa) @ 1 MHz DELAY_100MS macro local ripeti movff WREG, WREG_TEMP ; salva il registro W nella variabile "temporanea" movff STATUS, STATUS_TEMP ; salva i flag nella variabile "temporanea" movff BSR, BSR_TEMP ; salva il registro BSR banksel WREG_TEMP movlw 0x15 ; imposta il contatore a 0x1500 movwf contatore+1 clrf contatore ripeti decfsz contatore ; decrementa la variabile contatore (LSB) e salta ; l'istruzione seguente quanto contatore.LSB=0 bra ripeti ; ripeti decfsz contatore+1 ; decrementa la variabile contatore (MSB) e salta ; l'istruzione seguente quanto contatore.MSB=0 bra ripeti ; ripeti movff STATUS_TEMP, STATUS ; ripristina i flags movff WREG_TEMP, WREG ; ripristina il registro W movff BSR_TEMP, BSR ; ripristina il registro BSR endm DELAY_1S macro DELAY_100MS DELAY_100MS DELAY_100MS DELAY_100MS DELAY_100MS DELAY_100MS DELAY_100MS DELAY_100MS DELAY_100MS DELAY_100MS endm