;**************************
; 
; GENCW.ASM
;
; IT9DPX  #135 - FRANCO
;**************************

   PROCESSOR   16F84
   RADIX       DEC
   INCLUDE     "P16F84.INC"
    
   __CONFIG        3FF3H

        ORG     00H
VIA
        BSF     STATUS,RP0
        MOVLW   0X28 
        MOVWF   OPTION_REG
        MOVLW   0X10
        MOVWF   TRISA 
        MOVLW   15
        MOVWF   TRISB 
        BCF     STATUS,RP0
        CLRF    PORTA
        CLRF    35
        CALL    V9
GENERA 
        INCF    35,F
        MOVF    35,W
        XORLW   6
        BTFSC   STATUS,Z
        GOTO    SPAZIOR
        CALL    LPORTB
        GOTO    GENERA
SPAZIOR
        CALL    SPAZIOG
        GOTO    GENERA
RIT5       
        MOVWF   33
RIT6
        CLRF    34    
        CALL    TEMP3
RUOTA                    
        RLF     33,F
        BTFSC   STATUS,C
        GOTO    LINEAS
        CALL    PUNTO
RLINEA        
        INCF    34,F
        MOVF    34,W
        XORWF   36,W
        BTFSC   STATUS,Z
        RETURN
        GOTO    RUOTA
LINEAS
        CALL    LINEA
        GOTO    RLINEA           
PUNTO
        MOVLW  6
        MOVWF  PORTA
        CALL   TEMPO
        CLRF   PORTA
        CALL   TEMPO
        RETURN
LINEA
        MOVLW  6
        MOVWF  PORTA
TEMP4
        CALL   TEMPO
TEMP3        
        CALL   TEMPO
        CALL   TEMPO
        CLRF   PORTA
        CALL   TEMPO
        RETURN
TEMPO
        DECFSZ 32,F
        GOTO   TEMPO
        RETURN
SPAZIOG
        CALL  TEMP4
        CALL  TEMP3
        CLRF  35
        RETURN
LPORTB
        MOVF    PORTB,W
        ANDLW   15
        XORLW   15
        MOVWF   36
        ADDWF   PCL
        GOTO    LETT12
        GOTO    LETT123
        GOTO    LETT1234
        GOTO    LETT3
        GOTO    LETT4
        GOTO    NUMERI
        GOTO    SEGNI
        GOTO    LETTNUM
        GOTO    ACCENTI
        GOTO    ACCLETT
LETT12 
        MOVF    TMR0,W
        ANDLW   1
        MOVWF   36
        INCF    36,F
        CALL    CASO
        GOTO    RIT5
LETT123
        BTFSC   TMR0,3
        GOTO    LETT12
        MOVLW   3
        MOVWF   36
        CALL    CASO
        GOTO    RIT5 
LETT1234
        MOVF    TMR0,W
        ANDLW   3
        MOVWF   36
        INCF    36,F
        MOVLW   4
        XORWF   36,W
        BTFSC   STATUS,Z
        GOTO    LETT4
        CALL    CASO
        GOTO    RIT5
LETT3
        CALL    CASO   
        GOTO    RIT5
LETT4 
        CALL    CASO
        ANDLW   15
        CALL    INP4
        GOTO    RIT5
INP4
        ADDWF   PCL
        RETLW   0X00
        RETLW   0X10
        RETLW   0X20
        RETLW   0X40
        RETLW   0X60
        RETLW   0X70
        RETLW   0X80
        RETLW   0X90
        RETLW   0XA0
        RETLW   0XB0
        RETLW   0XC0
        RETLW   0XD0
        RETLW   0X00
        RETLW   0X10
        RETLW   0X20
        RETLW   0X40
NUMERI
        CALL    CASO
        ANDLW   15
        CALL    INP5
        GOTO    RIT5
INP5
        ADDWF   PCL
        RETLW   0XF8
        RETLW   0X78
        RETLW   0X38
        RETLW   0X18
        RETLW   0X08
        RETLW   0X00
        RETLW   0X80
        RETLW   0XC0
        RETLW   0XE0
        RETLW   0XF0
        RETLW   0XF8
        RETLW   0X78
        RETLW   0X38
        RETLW   0X18
        RETLW   0X08
        RETLW   0X00            
SEGNI
        CALL    CASO
        ANDLW   15
        CALL    INP6
        MOVWF   33
        ANDLW   3
        ADDWF   PCL
        GOTO    RIT6
        DECF    36,F
        GOTO    RIT6
INP6
        ADDWF   PCL
        RETLW   0X54
        RETLW   0XCC
        RETLW   0X78
        RETLW   0X30
        RETLW   0XE0
        RETLW   0XB4
        RETLW   0X84
        RETLW   0X48
        RETLW   0X14
        RETLW   0XB1
        RETLW   0X89
        RETLW   0X41
        RETLW   0X91
        RETLW   0XA9
        RETLW   0X51
        RETLW   0X11
LETTNUM
        BTFSC   TMR0,3
        GOTO    LETT1234
        MOVLW   5
        MOVWF   36
        GOTO    NUMERI        
ACCENTI 
        CALL    CASO
        ANDLW   3
        CALL    ACCENT
        MOVWF   33
        ANDLW   7
        MOVWF   36
        GOTO    RIT6
ACCENT
        ADDWF   PCL
        RETLW   0X6D
        RETLW   0X25
        RETLW   0XE4
        RETLW   0X34
ACCLETT
        BTFSC   TMR0,3
        GOTO    LETT1234
        GOTO    ACCENTI
CASO
        INCF    38
        BTFSC   38,0
        GOTO    CASO2
        MOVF    TMR0,W
        MOVWF   37
        RETURN
CASO2
        SWAPF   37,W
        RETURN
V9
        CALL    V3
        CALL    SPAZIOG
        CALL    V3
        CALL    SPAZIOG
        CALL    V3
        CALL    SPAZIOG
        RETURN
V3
        CALL   V1
        CALL   V1
        CALL   V1
        RETURN
V1
        MOVLW   4
        MOVWF   36
        MOVLW   0X10
        CALL    RIT5   
        RETURN 


        END    

