           LIST       p=PIC16F630
    #include "p16f630.inc"
; CONFIG
; __config 0xFFD5
 __CONFIG _FOSC_INTRCCLK & _WDTE_OFF & _PWRTE_OFF & _MCLRE_OFF & _BOREN_ON & _CP_OFF & _CPD_OFF
#define _XTAL_FREQ 4000000
PCL         equ         02h
TRISA       equ         05h
PORTA       equ         05h
STATUS      equ         03h
PORTC       equ         07h
TRISC       equ         07h
Reg_1       equ         20h
Reg_2       equ         21h
Reg_3       equ         22h
One_Wire_Byte equ       23h
Counter     equ         24h
DQ          equ         0
PORTDQ      equ         PORTA
TRISDQ      equ         TRISA
            org 0
            bsf         STATUS,5
            clrf        TRISC
            bcf         STATUS,5
begin       call        One_Wire_Init
            movlw       H'CC'
            call        One_Wire_Write_Byte
            movlw       H'44'
            call        One_Wire_Write_Byte
            call        delay_750us
            call        One_Wire_Init
            movlw       H'CC'
            call        One_Wire_Write_Byte
            movlw       H'BE'
            call        One_Wire_Write_Byte
            call        One_Wire_Read_Byte
            movwf       PORTC
            call        delay_5s
            call        One_Wire_Read_Byte
            movwf       PORTC
            call        delay_5s
            goto        begin

One_Wire_Init
            bcf         PORTDQ,DQ; PORTA,0
            bsf         STATUS,5
            bcf         TRISDQ,DQ; TRISA,0
            bcf         STATUS,5
            call        delay_500us
            bsf         STATUS,5
            bsf         TRISDQ,DQ; TRISA,1
            bcf         STATUS,5
            call        delay_500us
            return

One_Wire_Write_Byte
            movwf       One_Wire_Byte
            movlw       .8
            movwf       Counter
One_Wire_Write_Bit
            bcf         PORTDQ,DQ; PORTA,0
            bsf         STATUS,5
            bcf         TRISDQ,DQ; TRISA,0
            bcf         STATUS,5
            nop
            nop
            rrf         One_Wire_Byte
            bsf         STATUS,5
            btfsc       STATUS,0
            bsf         TRISDQ,DQ
            bcf         STATUS,5
            call        delay_60us
            bsf         STATUS,5
            bsf         TRISDQ,DQ; TRISA,0
            bcf         STATUS,5
            decfsz      Counter,1
            goto        One_Wire_Write_Bit
            return

One_Wire_Read_Byte
            movlw       .8
            movwf       Counter
One_Wire_Read_Bit
            bcf         PORTDQ,DQ; PORTA,0
            bsf         STATUS,5
            bcf         TRISDQ,DQ; TRISA,0
            bcf         STATUS,5
            nop
            nop
            nop
            nop
            nop
            nop
            bsf         STATUS,5
            bsf         TRISDQ,DQ; TRISA,1
            bcf         STATUS,5
            nop
            nop
            nop
            nop
            bcf         STATUS,0
            btfsc       PORTDQ,DQ
            bsf         STATUS,0
            rrf         One_Wire_Byte
            call        delay_60us
            decfsz      Counter,1
            goto        One_Wire_Read_Bit
            movf        One_Wire_Byte,0
            return

delay_60us  movlw       .19
            movwf       Reg_1
            decfsz      Reg_1,F
            goto        $-1
            nop
            nop
            return
delay_500us
            movlw       .166
            movwf       Reg_1
            decfsz      Reg_1,F
            goto        $-1
            nop
            return
delay_750us movlw       .249
            movwf       Reg_1
            decfsz      Reg_1,F
            goto        $-1
            nop
            nop
            return
delay_5s    movlw       .110
            movwf       Reg_1
            movlw       .94
            movwf       Reg_2
            movlw       .26
            movwf       Reg_3
            decfsz      Reg_1,F
            goto        $-1
            decfsz      Reg_2,F
            goto        $-3
            decfsz      Reg_3,F
            goto        $-5
            nop
            return
            end