; Source created with Parsic Version 3.x

; at              : 17.10.2000 00:39:30


; Project File    : C:\DOWNLO~1\BERLIN.PIC

; Project Version : 1.0.140

; Created         : 19.07.2000 07:35:00

; Last change     : 05.10.2000 18:46:00

	PROCESSOR 16C74A

	INCLUDE P16C74A.INC

	RADIX DEC


	__IDLOCS H'0100'

	__CONFIG _CP_OFF & _PWRTE_ON & _WDT_ON & _BODEN_ON & _XT_OSC

; Diverses

ZERO	EQU Z	; ZERO-Flag
CARRY	 EQU C	; CARRY-Flag


; Variable

SYS_WSAV	= 32	; located in Bank 0
SYS_SSAV	= 33	; located in Bank 0
SYS_PSAV	= 34	; located in Bank 0
SYS_TMP1	= 35	; located in Bank 0
SYS_TMP2	= 36	; located in Bank 0
SYS_TMP3	= 37	; located in Bank 0
SYS_TMP4	= 38	; located in Bank 0
SYS_TMP5	= 39	; located in Bank 0
SYS_TMP6	= 40	; located in Bank 0
SYS_TMP9	= 41	; located in Bank 0
SYS_TMP10	= 42	; located in Bank 0
TR1	= 43	; located in Bank 0
TR1_HI	= 44	; located in Bank 0
S4	= 45	; located in Bank 0
ZV1	= 46	; located in Bank 0
ZV1_FD	= 47	; located in Bank 0
ZV2	= 48	; located in Bank 0
ZV2_FD	= 49	; located in Bank 0
ZV3	= 50	; located in Bank 0
ZV3_FD	= 51	; located in Bank 0
ZV4	= 52	; located in Bank 0
ZV4_FD	= 53	; located in Bank 0
S2	= 54	; located in Bank 0
S3	= 55	; located in Bank 0
S0	= 56	; located in Bank 0
S0_HI	= 57	; located in Bank 0
ZV5	= 58	; located in Bank 0
ZV5_FD	= 59	; located in Bank 0
S1	= 60	; located in Bank 0
S1_HI	= 61	; located in Bank 0
LT1_FD	= 62	; located in Bank 0
LT2_FD	= 63	; located in Bank 0
LT3_FD	= 64	; located in Bank 0
TR2	= 65	; located in Bank 0
TR2_HI	= 66	; located in Bank 0
S5	= 67	; located in Bank 0
LT4_FD	= 68	; located in Bank 0
LT5_FD	= 69	; located in Bank 0
LT6_FD	= 70	; located in Bank 0
LT7_FD	= 71	; located in Bank 0
LT8_FD	= 72	; located in Bank 0
LT9_FD	= 73	; located in Bank 0
LT10_FD	= 74	; located in Bank 0
LT11_FD	= 75	; located in Bank 0
LT12_FD	= 76	; located in Bank 0
RAM	= 77	; located in Bank 0
SYS_WSAV2	= 160	; located in Bank 1

	ERRORLEVEL -302	; disable warning (Bankswitching)
	ERRORLEVEL -306	; disable warning (Pageswitching)

;****************************************
;Programmanfang
;****************************************

	ORG 0

	CLRF STATUS	; switch to RAM-Bank 0
	MOVLW HIGH SYS_INIT	; set page
	MOVWF PCLATH
	GOTO SYS_INIT

;****************************************
;Interrupt-Adress
;****************************************

	MOVWF SYS_WSAV	; save register
	SWAPF STATUS,W
	CLRF STATUS	; bank 0
	MOVWF SYS_SSAV
	MOVFW PCLATH
	MOVWF SYS_PSAV
	CLRF PCLATH

	BCF INTCON,T0IF	; Interrupt quitieren

	BCF STATUS,RP0	; Bank 0
	INCFSZ TR1,F
	GOTO SYS_INT_LABEL_0
	INCF TR1_HI,F

SYS_INT_LABEL_0
	INCFSZ TR2,F
	GOTO SYS_INT_LABEL_1
	INCF TR2_HI,F

SYS_INT_LABEL_1

EXITINT
	BCF STATUS,RP0	; Bank 0
	MOVFW SYS_PSAV
	MOVWF PCLATH

	SWAPF SYS_SSAV,W	; Register zurück
	MOVWF STATUS
	SWAPF SYS_WSAV,F
	SWAPF SYS_WSAV,W

	RETFIE	; RETurn From Interrupt and Enable GIE


;****************************************
; Subroutines
;****************************************

;***************************************************
; Subroutines for LB1
;***************************************************

LCD_LB1_INIT
	BCF STATUS,RP0	; Bank 0
	BCF PORTD,4	; ir-register
LCD_LB1_L1
	CALL LCD_LB1_OUT4
	CLRWDT
	DECFSZ SYS_TMP1,F
	GOTO LCD_LB1_L1

	MOVFW PORTD
	ANDLW H'F0'
	IORLW B'0011'	; Function Set
	MOVWF PORTD

	BSF PORTD,5	; write
	BCF PORTD,5

	BSF SYS_TMP1,5	; wait
LCD_LB1_L2
	CALL LCD_LB1_OUT4
	CLRWDT
	DECFSZ SYS_TMP1,F
	GOTO LCD_LB1_L2

	BSF PORTD,5	; write
	BCF PORTD,5

	CALL LCD_LB1_OUT4

	BSF PORTD,5	; write
	BCF PORTD,5

	CALL LCD_LB1_OUT4

	BCF PORTD,0	; 4-Bit Interface

	BSF PORTD,5	; write
	BCF PORTD,5

	CALL LCD_LB1_OUT4

	MOVLW B'00101000'	; Function Set 4-Bit,2-Lines
	CALL LCD_LB1_OUT

	MOVLW B'00001100'	; Display on, Cursor off, Blink off
	CALL LCD_LB1_OUT

	MOVLW B'00000110'	; Entrymode set
	CALL LCD_LB1_OUT

LCD_LB1_CLR
	BCF STATUS,RP0	; Bank 0
	BCF PORTD,4	; ir-register
	MOVLW B'00000001'	; Display clear
	CALL LCD_LB1_OUT

	BSF SYS_TMP1,5	; wait
LCD_LB1_L3
	CALL LCD_LB1_OUT4
	CLRWDT
	DECFSZ SYS_TMP1,F
	GOTO LCD_LB1_L3
	GOTO LCD_LB1_OUT4

;***************************************************

LCD_LB1_GOTOXY
	BCF STATUS,RP0	; Bank 0
	BCF PORTD,4	; ir-register
	MOVLW H'40'
	BTFSC SYS_TMP2,0	; Ypos
	ADDWF SYS_TMP1,F
	BSF SYS_TMP1,7	; select dd-ram
	GOTO LCD_LB1_OUT1

;***************************************************

LCD_LB1_WRITESTR
	BCF STATUS,RP0	; Bank 0
	BSF PORTD,4	; dd-ram
LCD_LB1_WRITESTR1
	CALL LCD_LB1_CHAROUT
	BSF INTCON,GIE
	ANDLW H'FF'	; last is zero
	BTFSC STATUS,ZERO
	RETURN

	MOVWF SYS_TMP1
	MOVLW HIGH LCD_LB1_OUT1	; set page
	MOVWF PCLATH
	CLRWDT
	CALL LCD_LB1_OUT1
	INCFSZ SYS_TMP4,F	; next char
	GOTO LCD_LB1_WRITESTR1
	INCF SYS_TMP5,F	; next page
	GOTO LCD_LB1_WRITESTR1

LCD_LB1_CHAROUT
	BCF INTCON,GIE
	MOVFW SYS_TMP5
	MOVWF PCLATH
	MOVFW SYS_TMP4
	MOVWF PCL

;***************************************************

LCD_LB1_DEZO10000

	MOVLW LOW 10000
	MOVWF SYS_TMP1
	MOVLW HIGH 10000
	MOVWF SYS_TMP2

	CALL LCD_LB1_CONVERTDEZ
	MOVF SYS_TMP9,F
	BTFSS STATUS,ZERO
	GOTO LCD_LB1_DEZO1000
	CALL LCD_LB1_CHECKNULL

LCD_LB1_DEZO1000

	MOVLW LOW 1000
	MOVWF SYS_TMP1
	MOVLW HIGH 1000
	MOVWF SYS_TMP2

	CALL LCD_LB1_CONVERTDEZ
	MOVF SYS_TMP9,F
	BTFSS STATUS,ZERO
	GOTO LCD_LB1_DEZO100
	CALL LCD_LB1_CHECKNULL

LCD_LB1_DEZO100

	MOVLW LOW 100
	MOVWF SYS_TMP1
	CLRF SYS_TMP2

	CALL LCD_LB1_CONVERTDEZ
	MOVF SYS_TMP9,F
	BTFSS STATUS,ZERO
	GOTO LCD_LB1_DEZO10
	CALL LCD_LB1_CHECKNULL

LCD_LB1_DEZO10

	MOVLW LOW 10
	MOVWF SYS_TMP1
	CLRF SYS_TMP2

	CALL LCD_LB1_CONVERTDEZ
	MOVF SYS_TMP9,F
	BTFSS STATUS,ZERO
	GOTO LCD_LB1_DEZO1
	CALL LCD_LB1_CHECKNULL

LCD_LB1_DEZO1
	MOVLW 48
	ADDWF SYS_TMP4,W
	GOTO LCD_LB1_WRITECHAR

;***************************************************

LCD_LB1_CONVERTDEZ
	BCF STATUS,RP0	; Bank 0
	MOVF SYS_TMP9,F
	BTFSS STATUS,ZERO
	DECF SYS_TMP9,F
	CLRF SYS_TMP6
LCD_LB1_CONVERTDEZ2
	INCF SYS_TMP6,F

	MOVFW SYS_TMP1
	SUBWF SYS_TMP4,F

	MOVFW SYS_TMP2
	BTFSS STATUS,CARRY
	INCFSZ SYS_TMP2,W
	SUBWF SYS_TMP5,F
	BTFSC STATUS,CARRY
	GOTO LCD_LB1_CONVERTDEZ2

	MOVFW SYS_TMP2
	ADDWF SYS_TMP5,F
	MOVFW SYS_TMP1
	ADDWF SYS_TMP4,F
	BTFSC STATUS,CARRY
	INCF SYS_TMP5,F

	DECF SYS_TMP6,W
	BTFSS STATUS,ZERO
	BSF SYS_TMP10,0
	RETURN

;***************************************************

LCD_LB1_CONVERTHEX
	ANDLW 15
	MOVWF SYS_TMP1
	MOVLW 48
	ADDWF SYS_TMP1,F
	MOVLW 58
	SUBWF SYS_TMP1,W
	BTFSS STATUS,CARRY
	GOTO $+3
	MOVLW 7
	ADDWF SYS_TMP1,F
	MOVFW SYS_TMP1

;***************************************************

LCD_LB1_WRITECHAR
	BCF STATUS,RP0	; Bank 0
	BSF PORTD,4	; dd-ram

;***************************************************

LCD_LB1_OUT
	BCF STATUS,RP0	; Bank 0
	MOVWF SYS_TMP1	; store
LCD_LB1_OUT1
	CLRF SYS_TMP3	; LCDWriteStr (first nibble)
LCD_LB1_OUT2
	SWAPF SYS_TMP1,W	;high nibble
LCD_LB1_OUT3
	ANDLW H'0F'	; mask
	MOVWF SYS_TMP2	; store
	MOVFW PORTD	; load port
	ANDLW H'F0'	; mask
	IORWF SYS_TMP2,W	; add cmd
	MOVWF PORTD	; out

	BSF PORTD,5	; E high
	BCF PORTD,5	; E low

	BTFSC SYS_TMP3,3	; ready ?
	GOTO LCD_LB1_OUT4	; yes
	BSF SYS_TMP3,3	; second nibble
	MOVFW SYS_TMP1
	GOTO LCD_LB1_OUT3	; next nibble

LCD_LB1_OUT4
LCD_LB1_OUTV
	DECFSZ SYS_TMP3,F
	GOTO LCD_LB1_OUTV
	RETURN

;***************************************************

LCD_LB1_CHECKNULL
	BTFSS STATUS,ZERO
	DECF SYS_TMP9,F
	MOVWF SYS_TMP1
	BTFSS STATUS,ZERO
	BSF SYS_TMP10,0
	MOVLW 48
	BTFSC SYS_TMP10,0
	ADDWF SYS_TMP1,f
	MOVLW 32
	BTFSS SYS_TMP10,0
	ADDWF SYS_TMP1,F
	MOVFW SYS_TMP1
	GOTO LCD_LB1_WRITECHAR
; 00CD

;****************************************
;Initialisierung
;****************************************


SYS_INIT

	MOVLW B'00100000'
	MOVWF INTCON

; Ausgangs-Pegel setzen, bevor die Richtung gesetzt wird

	BCF STATUS,RP0	; Bank 0
	MOVLW B'00000000'
	MOVWF PORTA

	MOVLW B'00000000'
	MOVWF PORTB

	MOVLW B'00000000'
	MOVWF PORTC

	MOVLW B'00000000'
	MOVWF PORTD

	MOVLW B'00000000'
	MOVWF PORTE

	MOVLW 15
	BSF STATUS,RP0	; Bank 1
	MOVWF OPTION_REG

	MOVLW 6	; all digital
	MOVWF ADCON1

; Richtung setzen

	MOVLW B'00000001'
	MOVWF TRISA

	MOVLW B'00010000'
	MOVWF TRISB

	MOVLW B'00000000'
	MOVWF TRISC

	MOVLW B'11000000'
	MOVWF TRISD

	MOVLW B'00000111'
	MOVWF TRISE

; init vars


; Clear RAM

	MOVLW 32
	MOVWF FSR
CR1
	CLRF INDF
	INCF FSR,F
	BTFSS FSR,7
	GOTO CR1
	BSF FSR,5
CR2
	CLRF INDF
	INCF FSR,F
	BTFSC FSR,7
	GOTO CR2


;***************************************************
; Init LCD -> LB1
;***************************************************

	CALL LCD_LB1_INIT

	BCF STATUS,RP0	; Bank 0
	CLRF TMR0
	BCF INTCON,T0IF
	BSF INTCON,GIE	; Interrupt freigeben

;**********************************
;******* Haupt-Programm ***********
;**********************************

MAIN

	CLRWDT

;***************************************************
; Timer -> TR1
;***************************************************

	MOVLW 7	; Test auf >=
	BCF STATUS,RP0	; Bank 0
	SUBWF TR1_HI,W	;F-W -> W
	BTFSS STATUS,ZERO
	GOTO LABEL_TR1_CHECK
	MOVLW 161
	SUBWF TR1,W	;F-W -> W
LABEL_TR1_CHECK
	BTFSS STATUS,CARRY
	GOTO LABEL_TR1_ENDE

LABEL_TR1_RESET
	MOVLW 7	; Test auf >=
	SUBWF TR1_HI,F	;F-W -> F
	MOVLW 161
	SUBWF TR1,F	;F-W -> F
	BTFSS STATUS,CARRY
	DECF TR1_HI,F

LABEL_TR1_SET	; toggel output
	BTFSC S4,1
	GOTO LABEL_TR1_CLR
	BSF S4,1
	GOTO LABEL_TR1_ENDE
LABEL_TR1_CLR
	BCF S4,1
LABEL_TR1_ENDE

;***************************************************
; Zähler -> ZV1
;***************************************************

	BCF STATUS,RP0	; Bank 0
	BTFSS S2,0	; Reset ?
	GOTO LABEL_ZV1_COUNT
	CLRF ZV1
	GOTO LABEL_ZV1_SETOUT

LABEL_ZV1_COUNT

; Test auf positive Flanke

	BCF STATUS,RP0	; Bank 0
	BTFSS PORTE,3
	GOTO LABEL_ZV1_SETFD
	BTFSC ZV1_FD,0
	GOTO LABEL_ZV1_SETFD

	BSF ZV1_FD,0


	BTFSC S2,3	; Vorwärts oder Rückwärts ?
	GOTO LABEL_ZV1_BACKWARD

	INCF ZV1,F
	GOTO LABEL_ZV1_SETOUT

LABEL_ZV1_BACKWARD
	BCF STATUS,RP0	; Bank 0
	DECF ZV1,F

LABEL_ZV1_SETOUT


LABEL_ZV1_SETFD

; Test auf negative Flanke

	BCF STATUS,RP0	; Bank 0
	BTFSC PORTE,3
	GOTO LABEL_ZV1_EXIT
	BCF ZV1_FD,0

LABEL_ZV1_EXIT

;***************************************************
; Vergleich -> IF1
;***************************************************

	MOVLW 59
	SUBWF ZV1,W	; F - W -> W

LABEL_IF1_CHECK
	BCF STATUS,RP0	; Bank 0
	BTFSS STATUS,CARRY	; Test auf -> >
	GOTO LABEL_IF1_FALSE
	BTFSC STATUS,ZERO
	GOTO LABEL_IF1_FALSE

LABEL_IF1_TRUE
	BSF S4,3
	GOTO LABEL_IF1_EXIT

LABEL_IF1_FALSE
	BCF S4,3

LABEL_IF1_EXIT
;***************************************************
; Zähler -> ZV2
;***************************************************

	BTFSS S2,1	; Reset ?
	GOTO LABEL_ZV2_COUNT
	CLRF ZV2
	GOTO LABEL_ZV2_SETOUT

LABEL_ZV2_COUNT

; Test auf positive Flanke

	BCF STATUS,RP0	; Bank 0
	BTFSS S2,0
	GOTO LABEL_ZV2_SETFD
	BTFSC ZV2_FD,0
	GOTO LABEL_ZV2_SETFD

	BSF ZV2_FD,0


	BTFSC S2,5	; Vorwärts oder Rückwärts ?
	GOTO LABEL_ZV2_BACKWARD

	INCF ZV2,F
	GOTO LABEL_ZV2_SETOUT

LABEL_ZV2_BACKWARD
	BCF STATUS,RP0	; Bank 0
	DECF ZV2,F

LABEL_ZV2_SETOUT


LABEL_ZV2_SETFD

; Test auf negative Flanke

	BCF STATUS,RP0	; Bank 0
	BTFSC S2,0
	GOTO LABEL_ZV2_EXIT
	BCF ZV2_FD,0

LABEL_ZV2_EXIT

;***************************************************
; Vergleich -> IF2
;***************************************************

	MOVLW 59
	SUBWF ZV2,W	; F - W -> W

LABEL_IF2_CHECK
	BCF STATUS,RP0	; Bank 0
	BTFSS STATUS,CARRY	; Test auf -> >
	GOTO LABEL_IF2_FALSE
	BTFSC STATUS,ZERO
	GOTO LABEL_IF2_FALSE

LABEL_IF2_TRUE
	BSF S4,4
	GOTO LABEL_IF2_EXIT

LABEL_IF2_FALSE
	BCF S4,4

LABEL_IF2_EXIT
;***************************************************
; Zähler -> ZV3
;***************************************************

	BTFSS S2,2	; Reset ?
	GOTO LABEL_ZV3_COUNT
	CLRF ZV3
	GOTO LABEL_ZV3_SETOUT

LABEL_ZV3_COUNT

; Test auf positive Flanke

	BCF STATUS,RP0	; Bank 0
	BTFSS S2,1
	GOTO LABEL_ZV3_SETFD
	BTFSC ZV3_FD,0
	GOTO LABEL_ZV3_SETFD

	BSF ZV3_FD,0


	BTFSC S2,4	; Vorwärts oder Rückwärts ?
	GOTO LABEL_ZV3_BACKWARD

	INCF ZV3,F
	GOTO LABEL_ZV3_SETOUT

LABEL_ZV3_BACKWARD
	BCF STATUS,RP0	; Bank 0
	DECF ZV3,F

LABEL_ZV3_SETOUT


LABEL_ZV3_SETFD

; Test auf negative Flanke

	BCF STATUS,RP0	; Bank 0
	BTFSC S2,1
	GOTO LABEL_ZV3_EXIT
	BCF ZV3_FD,0

LABEL_ZV3_EXIT

;***************************************************
; Vergleich -> IF3
;***************************************************

	MOVLW 23
	SUBWF ZV3,W	; F - W -> W

LABEL_IF3_CHECK
	BCF STATUS,RP0	; Bank 0
	BTFSS STATUS,ZERO	; Test auf -> =
	GOTO LABEL_IF3_FALSE

LABEL_IF3_TRUE
	BSF S4,5
	GOTO LABEL_IF3_EXIT

LABEL_IF3_FALSE
	BCF S4,5

LABEL_IF3_EXIT
;***************************************************
; Vergleich -> IF4
;***************************************************

	MOVLW 5
	SUBWF ZV2,W	; F - W -> W

LABEL_IF4_CHECK
	BCF STATUS,RP0	; Bank 0
	BTFSS STATUS,CARRY	; Test auf -> >=
	GOTO LABEL_IF4_FALSE

LABEL_IF4_TRUE
	BSF PORTA,1
	GOTO LABEL_IF4_EXIT

LABEL_IF4_FALSE
	BCF PORTA,1

LABEL_IF4_EXIT
;***************************************************
; Vergleich -> IF5
;***************************************************

	MOVLW 10
	SUBWF ZV2,W	; F - W -> W

LABEL_IF5_CHECK
	BCF STATUS,RP0	; Bank 0
	BTFSS STATUS,CARRY	; Test auf -> >=
	GOTO LABEL_IF5_FALSE

LABEL_IF5_TRUE
	BSF PORTA,2
	GOTO LABEL_IF5_EXIT

LABEL_IF5_FALSE
	BCF PORTA,2

LABEL_IF5_EXIT
;***************************************************
; Vergleich -> IF6
;***************************************************

	MOVLW 15
	SUBWF ZV2,W	; F - W -> W

LABEL_IF6_CHECK
	BCF STATUS,RP0	; Bank 0
	BTFSS STATUS,CARRY	; Test auf -> >=
	GOTO LABEL_IF6_FALSE

LABEL_IF6_TRUE
	BSF PORTA,3
	GOTO LABEL_IF6_EXIT

LABEL_IF6_FALSE
	BCF PORTA,3

LABEL_IF6_EXIT
;***************************************************
; Vergleich -> IF7
;***************************************************

	MOVLW 20
	SUBWF ZV2,W	; F - W -> W

LABEL_IF7_CHECK
	BCF STATUS,RP0	; Bank 0
	BTFSS STATUS,CARRY	; Test auf -> >=
	GOTO LABEL_IF7_FALSE

LABEL_IF7_TRUE
	BSF PORTA,4
	GOTO LABEL_IF7_EXIT

LABEL_IF7_FALSE
	BCF PORTA,4

LABEL_IF7_EXIT
;***************************************************
; Vergleich -> IF8
;***************************************************

	MOVLW 25
	SUBWF ZV2,W	; F - W -> W

LABEL_IF8_CHECK
	BCF STATUS,RP0	; Bank 0
	BTFSS STATUS,CARRY	; Test auf -> >=
	GOTO LABEL_IF8_FALSE

LABEL_IF8_TRUE
	BSF PORTA,5
	GOTO LABEL_IF8_EXIT

LABEL_IF8_FALSE
	BCF PORTA,5

LABEL_IF8_EXIT
;***************************************************
; Vergleich -> IF9
;***************************************************

	MOVLW 30
	SUBWF ZV2,W	; F - W -> W

LABEL_IF9_CHECK
	BCF STATUS,RP0	; Bank 0
	BTFSS STATUS,CARRY	; Test auf -> >=
	GOTO LABEL_IF9_FALSE

LABEL_IF9_TRUE
	BSF PORTA,6
	GOTO LABEL_IF9_EXIT

LABEL_IF9_FALSE
	BCF PORTA,6

LABEL_IF9_EXIT
;***************************************************
; Vergleich -> IF10
;***************************************************

	MOVLW 35
	SUBWF ZV2,W	; F - W -> W

LABEL_IF10_CHECK
	BCF STATUS,RP0	; Bank 0
	BTFSS STATUS,CARRY	; Test auf -> >=
	GOTO LABEL_IF10_FALSE

LABEL_IF10_TRUE
	BSF PORTA,7
	GOTO LABEL_IF10_EXIT

LABEL_IF10_FALSE
	BCF PORTA,7

LABEL_IF10_EXIT
;***************************************************
; Vergleich -> IF11
;***************************************************

	MOVLW 40
	SUBWF ZV2,W	; F - W -> W

LABEL_IF11_CHECK
	BCF STATUS,RP0	; Bank 0
	BTFSS STATUS,CARRY	; Test auf -> >=
	GOTO LABEL_IF11_FALSE

LABEL_IF11_TRUE
	BSF PORTB,0
	GOTO LABEL_IF11_EXIT

LABEL_IF11_FALSE
	BCF PORTB,0

LABEL_IF11_EXIT
;***************************************************
; Vergleich -> IF12
;***************************************************

	MOVLW 45
	SUBWF ZV2,W	; F - W -> W

LABEL_IF12_CHECK
	BCF STATUS,RP0	; Bank 0
	BTFSS STATUS,CARRY	; Test auf -> >=
	GOTO LABEL_IF12_FALSE

LABEL_IF12_TRUE
	BSF PORTB,1
	GOTO LABEL_IF12_EXIT

LABEL_IF12_FALSE
	BCF PORTB,1

LABEL_IF12_EXIT
;***************************************************
; Vergleich -> IF13
;***************************************************

	MOVLW 50
	SUBWF ZV2,W	; F - W -> W

LABEL_IF13_CHECK
	BCF STATUS,RP0	; Bank 0
	BTFSS STATUS,CARRY	; Test auf -> >=
	GOTO LABEL_IF13_FALSE

LABEL_IF13_TRUE
	BSF PORTB,2
	GOTO LABEL_IF13_EXIT

LABEL_IF13_FALSE
	BCF PORTB,2

LABEL_IF13_EXIT
;***************************************************
; Vergleich -> IF14
;***************************************************

	MOVLW 55
	SUBWF ZV2,W	; F - W -> W

LABEL_IF14_CHECK
	BCF STATUS,RP0	; Bank 0
	BTFSS STATUS,CARRY	; Test auf -> >=
	GOTO LABEL_IF14_FALSE

LABEL_IF14_TRUE
	BSF PORTB,3
	GOTO LABEL_IF14_EXIT

LABEL_IF14_FALSE
	BCF PORTB,3

LABEL_IF14_EXIT
;***************************************************
; Vergleich -> IF15
;***************************************************

	MOVLW 5
	SUBWF ZV3,W	; F - W -> W

LABEL_IF15_CHECK
	BCF STATUS,RP0	; Bank 0
	BTFSS STATUS,CARRY	; Test auf -> >=
	GOTO LABEL_IF15_FALSE

LABEL_IF15_TRUE
	BSF PORTC,0
	GOTO LABEL_IF15_EXIT

LABEL_IF15_FALSE
	BCF PORTC,0

LABEL_IF15_EXIT
;***************************************************
; Vergleich -> IF16
;***************************************************

	MOVLW 10
	SUBWF ZV3,W	; F - W -> W

LABEL_IF16_CHECK
	BCF STATUS,RP0	; Bank 0
	BTFSS STATUS,CARRY	; Test auf -> >=
	GOTO LABEL_IF16_FALSE

LABEL_IF16_TRUE
	BSF PORTC,1
	GOTO LABEL_IF16_EXIT

LABEL_IF16_FALSE
	BCF PORTC,1

LABEL_IF16_EXIT
;***************************************************
; Vergleich -> IF17
;***************************************************

	MOVLW 15
	SUBWF ZV3,W	; F - W -> W

LABEL_IF17_CHECK
	BCF STATUS,RP0	; Bank 0
	BTFSS STATUS,CARRY	; Test auf -> >=
	GOTO LABEL_IF17_FALSE

LABEL_IF17_TRUE
	BSF PORTC,2
	GOTO LABEL_IF17_EXIT

LABEL_IF17_FALSE
	BCF PORTC,2

LABEL_IF17_EXIT
;***************************************************
; Vergleich -> IF18
;***************************************************

	MOVLW 20
	SUBWF ZV3,W	; F - W -> W

LABEL_IF18_CHECK
	BCF STATUS,RP0	; Bank 0
	BTFSS STATUS,CARRY	; Test auf -> >=
	GOTO LABEL_IF18_FALSE

LABEL_IF18_TRUE
	BSF PORTC,3
	GOTO LABEL_IF18_EXIT

LABEL_IF18_FALSE
	BCF PORTC,3

LABEL_IF18_EXIT
;***************************************************
; Zähler -> ZV4
;***************************************************

	BTFSS S3,1	; Reset ?
	GOTO LABEL_ZV4_COUNT
	CLRF ZV4
	GOTO LABEL_ZV4_SETOUT

LABEL_ZV4_COUNT

; Test auf positive Flanke

	BCF STATUS,RP0	; Bank 0
	BTFSS S2,0
	GOTO LABEL_ZV4_SETFD
	BTFSC ZV4_FD,0
	GOTO LABEL_ZV4_SETFD

	BSF ZV4_FD,0


	BTFSC S3,2	; Vorwärts oder Rückwärts ?
	GOTO LABEL_ZV4_BACKWARD

	INCF ZV4,F
	GOTO LABEL_ZV4_SETOUT

LABEL_ZV4_BACKWARD
	BCF STATUS,RP0	; Bank 0
	DECF ZV4,F

LABEL_ZV4_SETOUT

; Output Q0

	BCF STATUS,RP0	; Bank 0
	BTFSS ZV4,0
	GOTO LABEL_ZV4_SETOUT0
	BSF S2,6
	GOTO LABEL_ZV4_SETOUT0_END
LABEL_ZV4_SETOUT0
	BCF S2,6
LABEL_ZV4_SETOUT0_END

; Output Q1

	BTFSS ZV4,1
	GOTO LABEL_ZV4_SETOUT1
	BSF S2,7
	GOTO LABEL_ZV4_SETOUT1_END
LABEL_ZV4_SETOUT1
	BCF S2,7
LABEL_ZV4_SETOUT1_END

; Output Q2

	BTFSS ZV4,2
	GOTO LABEL_ZV4_SETOUT2
	BSF S3,0
	GOTO LABEL_ZV4_SETOUT2_END
LABEL_ZV4_SETOUT2
	BCF S3,0
LABEL_ZV4_SETOUT2_END


LABEL_ZV4_SETFD

; Test auf negative Flanke

	BCF STATUS,RP0	; Bank 0
	BTFSC S2,0
	GOTO LABEL_ZV4_EXIT
	BCF ZV4_FD,0

LABEL_ZV4_EXIT

;***************************************************
; UND - Gatter -> LG1
;***************************************************

LABEL_LG1_1
	BTFSS S2,6
	GOTO LABEL_LG1_FALSE
LABEL_LG1_2
	BTFSC S2,7
	GOTO LABEL_LG1_FALSE
LABEL_LG1_3
	BTFSS S3,0
	GOTO LABEL_LG1_FALSE

LABEL_LG1_TRUE
	BSF S3,1
	GOTO LABEL_LG1_ENDE
LABEL_LG1_FALSE
	BCF STATUS,RP0	; Bank 0
	BCF S3,1
LABEL_LG1_ENDE
;***************************************************
; GND
;***************************************************

	BCF S3,2	; immer Low

;***************************************************
; Unterprogramm TAB_MIN aufrufen
;***************************************************

	MOVLW HIGH TAB_MIN	; set page
	MOVWF PCLATH
	BCF STATUS,CARRY
	RLF ZV4,W

	CALL TAB_MIN

	BCF STATUS,RP0	; Bank 0
	MOVWF S0


	INCF SYS_TMP1,W
	CALL TAB_MIN

	BCF STATUS,RP0	; Bank 0
	MOVWF S0_HI

	BSF INTCON,GIE
	BCF PCLATH,3	; Page 0
;***************************************************
; Verteiler -> BV1
;***************************************************

	BTFSC S0,0
	GOTO LABEL_BV1_0
	BCF PORTB,3
	GOTO LABEL_BV1_0_END
LABEL_BV1_0
	BSF PORTB,3
LABEL_BV1_0_END

;**********************************************

	BTFSC S0,1
	GOTO LABEL_BV1_1
	BCF PORTB,5
	GOTO LABEL_BV1_1_END
LABEL_BV1_1
	BSF PORTB,5
LABEL_BV1_1_END

;**********************************************

	BTFSC S0,2
	GOTO LABEL_BV1_2
	BCF PORTB,6
	GOTO LABEL_BV1_2_END
LABEL_BV1_2
	BSF PORTB,6
LABEL_BV1_2_END

;**********************************************

	BTFSC S0,3
	GOTO LABEL_BV1_3
	BCF PORTB,7
	GOTO LABEL_BV1_3_END
LABEL_BV1_3
	BSF PORTB,7
LABEL_BV1_3_END

;**********************************************


;***************************************************
; GND
;***************************************************

	BCF S2,4	; immer Low

;***************************************************
; GND
;***************************************************

	BCF S3,2	; immer Low

;***************************************************
; Zähler -> ZV5
;***************************************************

	BTFSS S3,7	; Reset ?
	GOTO LABEL_ZV5_COUNT
	CLRF ZV5
	GOTO LABEL_ZV5_SETOUT

LABEL_ZV5_COUNT

; Test auf positive Flanke

	BCF STATUS,RP0	; Bank 0
	BTFSS S2,1
	GOTO LABEL_ZV5_SETFD
	BTFSC ZV5_FD,0
	GOTO LABEL_ZV5_SETFD

	BSF ZV5_FD,0


	BTFSC S4,0	; Vorwärts oder Rückwärts ?
	GOTO LABEL_ZV5_BACKWARD

	INCF ZV5,F
	GOTO LABEL_ZV5_SETOUT

LABEL_ZV5_BACKWARD
	BCF STATUS,RP0	; Bank 0
	DECF ZV5,F

LABEL_ZV5_SETOUT

; Output Q0

	BCF STATUS,RP0	; Bank 0
	BTFSS ZV5,0
	GOTO LABEL_ZV5_SETOUT0
	BSF S3,3
	GOTO LABEL_ZV5_SETOUT0_END
LABEL_ZV5_SETOUT0
	BCF S3,3
LABEL_ZV5_SETOUT0_END

; Output Q1

	BTFSS ZV5,1
	GOTO LABEL_ZV5_SETOUT1
	BSF S3,4
	GOTO LABEL_ZV5_SETOUT1_END
LABEL_ZV5_SETOUT1
	BCF S3,4
LABEL_ZV5_SETOUT1_END

; Output Q2

	BTFSS ZV5,2
	GOTO LABEL_ZV5_SETOUT2
	BSF S3,5
	GOTO LABEL_ZV5_SETOUT2_END
LABEL_ZV5_SETOUT2
	BCF S3,5
LABEL_ZV5_SETOUT2_END


LABEL_ZV5_SETFD

; Test auf negative Flanke

	BCF STATUS,RP0	; Bank 0
	BTFSC S2,1
	GOTO LABEL_ZV5_EXIT
	BCF ZV5_FD,0

LABEL_ZV5_EXIT

;***************************************************
; UND - Gatter -> LG2
;***************************************************

LABEL_LG2_1
	BTFSS S3,3
	GOTO LABEL_LG2_FALSE
LABEL_LG2_2
	BTFSC S3,4
	GOTO LABEL_LG2_FALSE
LABEL_LG2_3
	BTFSS S3,5
	GOTO LABEL_LG2_FALSE

LABEL_LG2_TRUE
	BSF S3,6
	GOTO LABEL_LG2_ENDE
LABEL_LG2_FALSE
	BCF STATUS,RP0	; Bank 0
	BCF S3,6
LABEL_LG2_ENDE
;***************************************************
; GND
;***************************************************

	BCF S4,0	; immer Low

;***************************************************
; Unterprogramm TAB_STD aufrufen
;***************************************************

	MOVLW HIGH TAB_STD	; set page
	MOVWF PCLATH
	BCF STATUS,CARRY
	RLF ZV5,W

	CALL TAB_STD

	BCF STATUS,RP0	; Bank 0
	MOVWF S1


	INCF SYS_TMP1,W
	CALL TAB_STD

	BCF STATUS,RP0	; Bank 0
	MOVWF S1_HI

	BSF INTCON,GIE
	BCF PCLATH,3	; Page 0
;***************************************************
; Verteiler -> BV2
;***************************************************

	BTFSC S1,0
	GOTO LABEL_BV2_0
	BCF PORTC,4
	GOTO LABEL_BV2_0_END
LABEL_BV2_0
	BSF PORTC,4
LABEL_BV2_0_END

;**********************************************

	BTFSC S1,1
	GOTO LABEL_BV2_1
	BCF PORTC,5
	GOTO LABEL_BV2_1_END
LABEL_BV2_1
	BSF PORTC,5
LABEL_BV2_1_END

;**********************************************

	BTFSC S1,2
	GOTO LABEL_BV2_2
	BCF PORTC,6
	GOTO LABEL_BV2_2_END
LABEL_BV2_2
	BSF PORTC,6
LABEL_BV2_2_END

;**********************************************

	BTFSC S1,3
	GOTO LABEL_BV2_3
	BCF PORTC,7
	GOTO LABEL_BV2_3_END
LABEL_BV2_3
	BSF PORTC,7
LABEL_BV2_3_END

;**********************************************


;***************************************************
; UND - Gatter -> LG3
;***************************************************

LABEL_LG3_1
	BTFSS S4,1
	GOTO LABEL_LG3_FALSE
LABEL_LG3_2
	BTFSS S4,2
	GOTO LABEL_LG3_FALSE

LABEL_LG3_TRUE
	BSF PORTE,3
	GOTO LABEL_LG3_ENDE
LABEL_LG3_FALSE
	BCF STATUS,RP0	; Bank 0
	BCF PORTE,3
LABEL_LG3_ENDE
;***************************************************
; ODER - Gatter -> LG4
;***************************************************

LABEL_LG4_1
	BTFSC PORTE,1
	GOTO LABEL_LG4_TRUE
LABEL_LG4_2
	BTFSC S4,3
	GOTO LABEL_LG4_TRUE

LABEL_LG4_FALSE
	BCF S2,0
	GOTO LABEL_LG4_ENDE
LABEL_LG4_TRUE
	BCF STATUS,RP0	; Bank 0
	BSF S2,0
LABEL_LG4_ENDE
;***************************************************
; ODER - Gatter -> LG5
;***************************************************

LABEL_LG5_1
	BTFSC PORTE,2
	GOTO LABEL_LG5_TRUE
LABEL_LG5_2
	BTFSC S4,4
	GOTO LABEL_LG5_TRUE

LABEL_LG5_FALSE
	BCF S2,1
	GOTO LABEL_LG5_ENDE
LABEL_LG5_TRUE
	BCF STATUS,RP0	; Bank 0
	BSF S2,1
LABEL_LG5_ENDE
;***************************************************
; UND - Gatter -> LG6
;***************************************************

LABEL_LG6_1
	BTFSS S4,4
	GOTO LABEL_LG6_FALSE
LABEL_LG6_2
	BTFSS S4,5
	GOTO LABEL_LG6_FALSE
LABEL_LG6_3
	BTFSS S4,6
	GOTO LABEL_LG6_FALSE

LABEL_LG6_TRUE
	BSF S2,2
	GOTO LABEL_LG6_ENDE
LABEL_LG6_FALSE
	BCF STATUS,RP0	; Bank 0
	BCF S2,2
LABEL_LG6_ENDE
;***************************************************
; ODER - Gatter -> LG7
;***************************************************

LABEL_LG7_1
	BTFSC S3,6
	GOTO LABEL_LG7_TRUE
LABEL_LG7_2
	BTFSC S2,2
	GOTO LABEL_LG7_TRUE

LABEL_LG7_FALSE
	BCF S3,7
	GOTO LABEL_LG7_ENDE
LABEL_LG7_TRUE
	BCF STATUS,RP0	; Bank 0
	BSF S3,7
LABEL_LG7_ENDE
;***************************************************
; UND - Gatter -> LG8
;***************************************************

LABEL_LG8_1
	BTFSS S3,3
	GOTO LABEL_LG8_FALSE
LABEL_LG8_2
	BTFSS S3,4
	GOTO LABEL_LG8_FALSE

LABEL_LG8_TRUE
	BSF S4,6
	GOTO LABEL_LG8_ENDE
LABEL_LG8_FALSE
	BCF STATUS,RP0	; Bank 0
	BCF S4,6
LABEL_LG8_ENDE
;***************************************************
; LCD -> LT1
;***************************************************

; test of positiv edge

	BTFSC LT1_FD,0
	GOTO LABEL_LT1_SETFD
	BTFSS S5,0
	GOTO LABEL_LT1_SETFD


	MOVLW 4
	MOVWF SYS_TMP1
	MOVLW 1
	MOVWF SYS_TMP2

	MOVLW HIGH LCD_LB1_GOTOXY	; set page
	MOVWF PCLATH
	CALL LCD_LB1_GOTOXY

	BCF STATUS,RP0	; Bank 0
	MOVFW ZV3
	MOVWF SYS_TMP4
	CLRF SYS_TMP5

	BSF SYS_TMP10,0
	MOVLW 2
	MOVWF SYS_TMP9
	MOVLW HIGH LCD_LB1_DEZO100	; set page
	MOVWF PCLATH
	CALL LCD_LB1_DEZO100
	BCF PCLATH,3	; Page 0
LABEL_LT1_SETFD

	BCF STATUS,RP0	; Bank 0
	BTFSS S5,0
	GOTO LABEL_LT1_SETFD2
	BSF LT1_FD,0
	GOTO LABEL_LT1_END
LABEL_LT1_SETFD2
	BCF STATUS,RP0	; Bank 0
	BCF LT1_FD,0
LABEL_LT1_END

;***************************************************
; LCD -> LT2
;***************************************************

; test of positiv edge

	BTFSC LT2_FD,0
	GOTO LABEL_LT2_SETFD
	BTFSS S5,0
	GOTO LABEL_LT2_SETFD


	MOVLW 6
	MOVWF SYS_TMP1
	MOVLW 1
	MOVWF SYS_TMP2

	MOVLW HIGH LCD_LB1_GOTOXY	; set page
	MOVWF PCLATH
	CALL LCD_LB1_GOTOXY

	MOVLW LOW TAB_LT2
	BCF STATUS,RP0	; Bank 0
	MOVWF SYS_TMP4
	MOVLW HIGH TAB_LT2
	MOVWF SYS_TMP5

	MOVLW HIGH LCD_LB1_WRITESTR	; set page
	MOVWF PCLATH

	CALL LCD_LB1_WRITESTR

	BCF PCLATH,3	; Page 0
LABEL_LT2_SETFD

	BCF STATUS,RP0	; Bank 0
	BTFSS S5,0
	GOTO LABEL_LT2_SETFD2
	BSF LT2_FD,0
	GOTO LABEL_LT2_END
LABEL_LT2_SETFD2
	BCF STATUS,RP0	; Bank 0
	BCF LT2_FD,0
LABEL_LT2_END

;***************************************************
; LCD -> LT3
;***************************************************

; test of positiv edge

	BTFSC LT3_FD,0
	GOTO LABEL_LT3_SETFD
	BTFSS S5,0
	GOTO LABEL_LT3_SETFD


	MOVLW 7
	MOVWF SYS_TMP1
	MOVLW 1
	MOVWF SYS_TMP2

	MOVLW HIGH LCD_LB1_GOTOXY	; set page
	MOVWF PCLATH
	CALL LCD_LB1_GOTOXY

	BCF STATUS,RP0	; Bank 0
	MOVFW ZV2
	MOVWF SYS_TMP4
	CLRF SYS_TMP5

	BSF SYS_TMP10,0
	MOVLW 2
	MOVWF SYS_TMP9
	MOVLW HIGH LCD_LB1_DEZO100	; set page
	MOVWF PCLATH
	CALL LCD_LB1_DEZO100
	BCF PCLATH,3	; Page 0
LABEL_LT3_SETFD

	BCF STATUS,RP0	; Bank 0
	BTFSS S5,0
	GOTO LABEL_LT3_SETFD2
	BSF LT3_FD,0
	GOTO LABEL_LT3_END
LABEL_LT3_SETFD2
	BCF STATUS,RP0	; Bank 0
	BCF LT3_FD,0
LABEL_LT3_END

;***************************************************
; Timer -> TR2
;***************************************************

	MOVLW 0	; Test auf >=
	SUBWF TR2_HI,W	;F-W -> W
	BTFSS STATUS,ZERO
	GOTO LABEL_TR2_CHECK
	MOVLW 195
	SUBWF TR2,W	;F-W -> W
LABEL_TR2_CHECK
	BTFSS STATUS,CARRY
	GOTO LABEL_TR2_ENDE

LABEL_TR2_RESET
	MOVLW 0	; Test auf >=
	SUBWF TR2_HI,F	;F-W -> F
	MOVLW 195
	SUBWF TR2,F	;F-W -> F
	BTFSS STATUS,CARRY
	DECF TR2_HI,F

LABEL_TR2_SET	; toggel output
	BTFSC S5,0
	GOTO LABEL_TR2_CLR
	BSF S5,0
	GOTO LABEL_TR2_ENDE
LABEL_TR2_CLR
	BCF S5,0
LABEL_TR2_ENDE

;***************************************************
; LCD -> LT4
;***************************************************

; test of positiv edge

	BCF STATUS,RP0	; Bank 0
	BTFSC LT4_FD,0
	GOTO LABEL_LT4_SETFD
	BTFSS S4,7
	GOTO LABEL_LT4_SETFD


	MOVLW 9
	MOVWF SYS_TMP1
	MOVLW 1
	MOVWF SYS_TMP2

	MOVLW HIGH LCD_LB1_GOTOXY	; set page
	MOVWF PCLATH
	CALL LCD_LB1_GOTOXY

	MOVLW LOW TAB_LT4
	BCF STATUS,RP0	; Bank 0
	MOVWF SYS_TMP4
	MOVLW HIGH TAB_LT4
	MOVWF SYS_TMP5

	MOVLW HIGH LCD_LB1_WRITESTR	; set page
	MOVWF PCLATH

	CALL LCD_LB1_WRITESTR

	BCF PCLATH,3	; Page 0
LABEL_LT4_SETFD

	BCF STATUS,RP0	; Bank 0
	BTFSS S4,7
	GOTO LABEL_LT4_SETFD2
	BSF LT4_FD,0
	GOTO LABEL_LT4_END
LABEL_LT4_SETFD2
	BCF STATUS,RP0	; Bank 0
	BCF LT4_FD,0
LABEL_LT4_END

;***************************************************
; LCD -> LT5
;***************************************************

; test of positiv edge

	BTFSC LT5_FD,0
	GOTO LABEL_LT5_SETFD
	BTFSS S4,7
	GOTO LABEL_LT5_SETFD


	MOVLW 10
	MOVWF SYS_TMP1
	MOVLW 1
	MOVWF SYS_TMP2

	MOVLW HIGH LCD_LB1_GOTOXY	; set page
	MOVWF PCLATH
	CALL LCD_LB1_GOTOXY

	BCF STATUS,RP0	; Bank 0
	MOVFW ZV1
	MOVWF SYS_TMP4
	CLRF SYS_TMP5

	BSF SYS_TMP10,0
	MOVLW 2
	MOVWF SYS_TMP9
	MOVLW HIGH LCD_LB1_DEZO100	; set page
	MOVWF PCLATH
	CALL LCD_LB1_DEZO100
	BCF PCLATH,3	; Page 0
LABEL_LT5_SETFD

	BCF STATUS,RP0	; Bank 0
	BTFSS S4,7
	GOTO LABEL_LT5_SETFD2
	BSF LT5_FD,0
	GOTO LABEL_LT5_END
LABEL_LT5_SETFD2
	BCF STATUS,RP0	; Bank 0
	BCF LT5_FD,0
LABEL_LT5_END

;***************************************************
; LCD -> LT6
;***************************************************

; test of positiv edge

	BTFSC LT6_FD,0
	GOTO LABEL_LT6_SETFD
	BTFSS S5,1
	GOTO LABEL_LT6_SETFD


	MOVLW 0
	MOVWF SYS_TMP1
	MOVLW 0
	MOVWF SYS_TMP2

	MOVLW HIGH LCD_LB1_GOTOXY	; set page
	MOVWF PCLATH
	CALL LCD_LB1_GOTOXY

	MOVLW LOW TAB_LT6
	BCF STATUS,RP0	; Bank 0
	MOVWF SYS_TMP4
	MOVLW HIGH TAB_LT6
	MOVWF SYS_TMP5

	MOVLW HIGH LCD_LB1_WRITESTR	; set page
	MOVWF PCLATH

	CALL LCD_LB1_WRITESTR

	BCF PCLATH,3	; Page 0
LABEL_LT6_SETFD

	BCF STATUS,RP0	; Bank 0
	BTFSS S5,1
	GOTO LABEL_LT6_SETFD2
	BSF LT6_FD,0
	GOTO LABEL_LT6_END
LABEL_LT6_SETFD2
	BCF STATUS,RP0	; Bank 0
	BCF LT6_FD,0
LABEL_LT6_END

;***************************************************
; LCD -> LT7
;***************************************************

; test of positiv edge

	BTFSC LT7_FD,0
	GOTO LABEL_LT7_SETFD
	BTFSS S5,1
	GOTO LABEL_LT7_SETFD


	MOVLW 0
	MOVWF SYS_TMP1
	MOVLW 1
	MOVWF SYS_TMP2

	MOVLW HIGH LCD_LB1_GOTOXY	; set page
	MOVWF PCLATH
	CALL LCD_LB1_GOTOXY

	MOVLW LOW TAB_LT7
	BCF STATUS,RP0	; Bank 0
	MOVWF SYS_TMP4
	MOVLW HIGH TAB_LT7
	MOVWF SYS_TMP5

	MOVLW HIGH LCD_LB1_WRITESTR	; set page
	MOVWF PCLATH

	CALL LCD_LB1_WRITESTR

	BCF PCLATH,3	; Page 0
LABEL_LT7_SETFD

	BCF STATUS,RP0	; Bank 0
	BTFSS S5,1
	GOTO LABEL_LT7_SETFD2
	BSF LT7_FD,0
	GOTO LABEL_LT7_END
LABEL_LT7_SETFD2
	BCF STATUS,RP0	; Bank 0
	BCF LT7_FD,0
LABEL_LT7_END

;***************************************************
; UND - Gatter -> LG9
;***************************************************

LABEL_LG9_1
	BTFSS S4,2
	GOTO LABEL_LG9_FALSE
LABEL_LG9_2
	BTFSS S5,0
	GOTO LABEL_LG9_FALSE

LABEL_LG9_TRUE
	BSF S4,7
	GOTO LABEL_LG9_ENDE
LABEL_LG9_FALSE
	BCF STATUS,RP0	; Bank 0
	BCF S4,7
LABEL_LG9_ENDE
;***************************************************
; UND - Gatter -> LG10
;***************************************************

LABEL_LG10_1
	BTFSS S5,0
	GOTO LABEL_LG10_FALSE
LABEL_LG10_2
	BTFSC S4,2
	GOTO LABEL_LG10_FALSE

LABEL_LG10_TRUE
	BSF S5,1
	GOTO LABEL_LG10_ENDE
LABEL_LG10_FALSE
	BCF STATUS,RP0	; Bank 0
	BCF S5,1
LABEL_LG10_ENDE
;***************************************************
; LCD -> LT8
;***************************************************

; test of positiv edge

	BTFSC LT8_FD,0
	GOTO LABEL_LT8_SETFD
	BTFSS S4,7
	GOTO LABEL_LT8_SETFD


	MOVLW 12
	MOVWF SYS_TMP1
	MOVLW 1
	MOVWF SYS_TMP2

	MOVLW HIGH LCD_LB1_GOTOXY	; set page
	MOVWF PCLATH
	CALL LCD_LB1_GOTOXY

	MOVLW LOW TAB_LT8
	BCF STATUS,RP0	; Bank 0
	MOVWF SYS_TMP4
	MOVLW HIGH TAB_LT8
	MOVWF SYS_TMP5

	MOVLW HIGH LCD_LB1_WRITESTR	; set page
	MOVWF PCLATH

	CALL LCD_LB1_WRITESTR

	BCF PCLATH,3	; Page 0
LABEL_LT8_SETFD

	BCF STATUS,RP0	; Bank 0
	BTFSS S4,7
	GOTO LABEL_LT8_SETFD2
	BSF LT8_FD,0
	GOTO LABEL_LT8_END
LABEL_LT8_SETFD2
	BCF STATUS,RP0	; Bank 0
	BCF LT8_FD,0
LABEL_LT8_END

;***************************************************
; LCD -> LT9
;***************************************************

; test of positiv edge

	BTFSC LT9_FD,0
	GOTO LABEL_LT9_SETFD
	BTFSS S4,7
	GOTO LABEL_LT9_SETFD


	MOVLW 0
	MOVWF SYS_TMP1
	MOVLW 0
	MOVWF SYS_TMP2

	MOVLW HIGH LCD_LB1_GOTOXY	; set page
	MOVWF PCLATH
	CALL LCD_LB1_GOTOXY

	MOVLW LOW TAB_LT9
	BCF STATUS,RP0	; Bank 0
	MOVWF SYS_TMP4
	MOVLW HIGH TAB_LT9
	MOVWF SYS_TMP5

	MOVLW HIGH LCD_LB1_WRITESTR	; set page
	MOVWF PCLATH

	CALL LCD_LB1_WRITESTR

	BCF PCLATH,3	; Page 0
LABEL_LT9_SETFD

	BCF STATUS,RP0	; Bank 0
	BTFSS S4,7
	GOTO LABEL_LT9_SETFD2
	BSF LT9_FD,0
	GOTO LABEL_LT9_END
LABEL_LT9_SETFD2
	BCF STATUS,RP0	; Bank 0
	BCF LT9_FD,0
LABEL_LT9_END

;***************************************************
; LCD -> LT10
;***************************************************

; test of positiv edge

	BTFSC LT10_FD,0
	GOTO LABEL_LT10_SETFD
	BTFSS S4,7
	GOTO LABEL_LT10_SETFD


	MOVLW 14
	MOVWF SYS_TMP1
	MOVLW 0
	MOVWF SYS_TMP2

	MOVLW HIGH LCD_LB1_GOTOXY	; set page
	MOVWF PCLATH
	CALL LCD_LB1_GOTOXY

	MOVLW LOW TAB_LT10
	BCF STATUS,RP0	; Bank 0
	MOVWF SYS_TMP4
	MOVLW HIGH TAB_LT10
	MOVWF SYS_TMP5

	MOVLW HIGH LCD_LB1_WRITESTR	; set page
	MOVWF PCLATH

	CALL LCD_LB1_WRITESTR

	BCF PCLATH,3	; Page 0
LABEL_LT10_SETFD

	BCF STATUS,RP0	; Bank 0
	BTFSS S4,7
	GOTO LABEL_LT10_SETFD2
	BSF LT10_FD,0
	GOTO LABEL_LT10_END
LABEL_LT10_SETFD2
	BCF STATUS,RP0	; Bank 0
	BCF LT10_FD,0
LABEL_LT10_END

;***************************************************
; LCD -> LT11
;***************************************************

; test of positiv edge

	BTFSC LT11_FD,0
	GOTO LABEL_LT11_SETFD
	BTFSS S4,7
	GOTO LABEL_LT11_SETFD


	MOVLW 0
	MOVWF SYS_TMP1
	MOVLW 1
	MOVWF SYS_TMP2

	MOVLW HIGH LCD_LB1_GOTOXY	; set page
	MOVWF PCLATH
	CALL LCD_LB1_GOTOXY

	MOVLW LOW TAB_LT11
	BCF STATUS,RP0	; Bank 0
	MOVWF SYS_TMP4
	MOVLW HIGH TAB_LT11
	MOVWF SYS_TMP5

	MOVLW HIGH LCD_LB1_WRITESTR	; set page
	MOVWF PCLATH

	CALL LCD_LB1_WRITESTR

	BCF PCLATH,3	; Page 0
LABEL_LT11_SETFD

	BCF STATUS,RP0	; Bank 0
	BTFSS S4,7
	GOTO LABEL_LT11_SETFD2
	BSF LT11_FD,0
	GOTO LABEL_LT11_END
LABEL_LT11_SETFD2
	BCF STATUS,RP0	; Bank 0
	BCF LT11_FD,0
LABEL_LT11_END

;***************************************************
; LCD -> LT12
;***************************************************

; test of positiv edge

	BTFSC LT12_FD,0
	GOTO LABEL_LT12_SETFD
	BTFSS S5,1
	GOTO LABEL_LT12_SETFD


	MOVLW 9
	MOVWF SYS_TMP1
	MOVLW 1
	MOVWF SYS_TMP2

	MOVLW HIGH LCD_LB1_GOTOXY	; set page
	MOVWF PCLATH
	CALL LCD_LB1_GOTOXY

	MOVLW LOW TAB_LT12
	BCF STATUS,RP0	; Bank 0
	MOVWF SYS_TMP4
	MOVLW HIGH TAB_LT12
	MOVWF SYS_TMP5

	MOVLW HIGH LCD_LB1_WRITESTR	; set page
	MOVWF PCLATH

	CALL LCD_LB1_WRITESTR

	BCF PCLATH,3	; Page 0
LABEL_LT12_SETFD

	BCF STATUS,RP0	; Bank 0
	BTFSS S5,1
	GOTO LABEL_LT12_SETFD2
	BSF LT12_FD,0
	GOTO LABEL_LT12_END
LABEL_LT12_SETFD2
	BCF STATUS,RP0	; Bank 0
	BCF LT12_FD,0
LABEL_LT12_END

;***************************************************
; GND
;***************************************************

	BCF S2,3	; immer Low

;***************************************************
; GND
;***************************************************

	BCF S2,5	; immer Low

;****************************************

	GOTO MAIN




TAB_LT2
	RETLW 58	; :
	RETLW 0	; end




TAB_LT4
	RETLW 58	; :
	RETLW 0	; end




TAB_LT6
	RETLW 72	; H
	RETLW 111	; o
	RETLW 108	; l
	RETLW 109	; m
	RETLW 32	;  
	RETLW 68	; D
	RETLW 101	; e
	RETLW 117	; u
	RETLW 116	; t
	RETLW 115	; s
	RETLW 99	; c
	RETLW 104	; h
	RETLW 108	; l
	RETLW 97	; a
	RETLW 110	; n
	RETLW 100	; d
	RETLW 0	; end


TAB_LT7
	RETLW 83	; S
	RETLW 101	; e
	RETLW 116	; t
	RETLW 33	; !
	RETLW 0	; end


TAB_LT8
	RETLW 32	;  
	RETLW 32	;  
	RETLW 32	;  
	RETLW 32	;  
	RETLW 32	;  
	RETLW 32	;  
	RETLW 0	; end


TAB_LT9
	RETLW 32	;  
	RETLW 32	;  
	RETLW 66	; B
	RETLW 101	; e
	RETLW 114	; r
	RETLW 108	; l
	RETLW 105	; i
	RETLW 110	; n
	RETLW 101	; e
	RETLW 114	; r
	RETLW 32	;  
	RETLW 85	; U
	RETLW 104	; h
	RETLW 114	; r
	RETLW 0	; end


TAB_LT10
	RETLW 32	;  
	RETLW 32	;  
	RETLW 32	;  
	RETLW 32	;  
	RETLW 0	; end


TAB_LT11
	RETLW 32	;  
	RETLW 32	;  
	RETLW 32	;  
	RETLW 32	;  
	RETLW 0	; end


TAB_LT12
	RETLW 32	;  
	RETLW 61	; =
	RETLW 72	; H
	RETLW 58	; :
	RETLW 77	; M
	RETLW 105	; i
	RETLW 110	; n
	RETLW 0	; end

	ORG 4074
;***************************************************
; Table -> TAB_MIN
;***************************************************

TAB_MIN

	MOVWF SYS_TMP1
	MOVLW HIGH TAB_MIN_WERTE
	MOVWF PCLATH
	MOVFW SYS_TMP1
	BCF INTCON,GIE
	ADDWF PCL,F

TAB_MIN_WERTE

	RETLW 0
	RETLW 0
	RETLW 1
	RETLW 0
	RETLW 3
	RETLW 0
	RETLW 7
	RETLW 0
	RETLW 15
	RETLW 0
	RETLW 5
	RETLW 0
	RETLW 6
	RETLW 0
	RETLW 7
	RETLW 0

	ORG 4052
;***************************************************
; Table -> TAB_STD
;***************************************************

TAB_STD

	MOVWF SYS_TMP1
	MOVLW HIGH TAB_STD_WERTE
	MOVWF PCLATH
	MOVFW SYS_TMP1
	BCF INTCON,GIE
	ADDWF PCL,F

TAB_STD_WERTE

	RETLW 0
	RETLW 0
	RETLW 1
	RETLW 0
	RETLW 3
	RETLW 0
	RETLW 7
	RETLW 0
	RETLW 15
	RETLW 0
	RETLW 5
	RETLW 0
	RETLW 6
	RETLW 0
	RETLW 7
	RETLW 0


	END

