Code:
D_ScanForNull:
  $if D_CheckNulls = True

    D_Counter = 0                                 ' initialise counter

    Do                                            ' head of loop, test condition at the end

      $if _core = 16
        D_Data = Ptr8(D_Address)                  ' get data
      $else
        If D_Address < $100 Then
          Bcf STATUS, IRP                         ' Set IRP to 0
        Else
          Bsf STATUS, IRP                         ' Set IRP to 1
        End If
        D_Data = D_Address                        '
        Movf D_Data, W                            ' Initialize FSR - workaround
        Movwf FSR
        Movf INDF, W                              ' read (D_Address) into W
        Wreg_Byte D_Data
      $endif

      If D_Data <> 0 Then Break
      If D_Address > D_AddressEnd Then Break      ' test for overrun
      If D_Counter = $FF Then Break
      Inc D_Counter                               ' adjust counter
      Inc D_Address                               ' adjust address

    Loop

    D_Address = D_AddressBack                     ' either way restore address
    If D_Counter > (D_DataBlock - 1) Then         ' throw back the little ones (both address and len correct)
      D_DataLen = D_Counter                       ' set len
      GoSub D_Send_NullBlock                      ' send block of contiguous NULLs
    End If

  $endif
  Return
Code:
D_ScanForNull:
  $if D_CheckNulls = True

    D_Counter = 0                                 ' initialise counter

    Do                                            ' head of loop, test condition at the end

      $if _core = 16
        D_Data = Ptr8(D_Address)                  ' get data
      $else
        If D_Address < $100 Then
          Bcf STATUS, IRP                         ' Set IRP to 0
        Else
          Bsf STATUS, IRP                         ' Set IRP to 1
        End If
        D_Data = D_Address                        '
        Movf D_Data, W                            ' Initialize FSR - workaround
        Movwf FSR
        Movf INDF, W                              ' read (D_Address) into W
        Wreg_Byte D_Data
      $endif

      If D_Data <> 0 Then Break
      If D_Address > D_AddressEnd Then Break      ' test for overrun
      If D_Counter = $FF Then Break
      Inc D_Counter                               ' adjust counter
      Inc D_Address                               ' adjust address

    Loop

    D_Address = D_AddressBack                     ' either way restore address
    If D_Counter > (D_DataBlock - 1) Then         ' throw back the little ones (both address and len correct)
      D_DataLen = D_Counter                       ' set len
      GoSub D_Send_NullBlock                      ' send block of contiguous NULLs
    End If

  $endif
  Return