Advertisement
Leo_F

Untitled

Mar 6th, 2018
2,477
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MPASM 2.47 KB | None | 0 0
  1. MAIN        CALL        EC8INIT
  2.         CALL        E88INIT
  3.         CALL        EKINIT
  4.         CALL        ELINIT
  5.         CALL        ELCDINIT
  6.         CALL        ESINIT
  7.         LFSR        1,S88DISP
  8.         BSF     INTCON, GIE ; < Allow Global interrupt! >
  9.        
  10.         MOVLW   low(LCDTEXT)
  11.         MOVWF   TBLPTRL         ; Load in to TABLPTRL
  12.         MOVLW   high(LCDTEXT)   ; Get high byte of code table
  13.         MOVWF   TBLPTRH         ; Load in to TABLEPTRH          ; Fetch data from TABLPTR
  14.         CALL    LOADMSG
  15.                
  16.        
  17. LOOP        CLRF        PORTD       ; Clear PORTD      
  18.         CALL        EC8NEXT     ; Advance to and activate next column
  19.         CALL        EKDOWNQ     ; Check if any key in column is pressed
  20.         BTFSS       WREG,7      ; Button pressed?                                          
  21.         CALL        BTN_PRESS   ;    ... yes, call BTN_PRESS
  22.         CALL        EC8FREE     ; Turn off all columns
  23.         MOVF        IKTEMP, W   ; Move last pressed key to work
  24.         CALL        GET_NRCODE  ; Look up 7seg code in table
  25.         MOVWF       PORTD       ; Present code on PORTD
  26.         BSF     PORTA, RA1  ; Activate Column 0
  27.         CALL        ED10MS      ; Let it glow for a while..
  28.         BCF     PORTA, RA1  ; Turn off Column 0
  29.        
  30.         GOTO        LOOP
  31.  
  32.        
  33. BTN_PRESS   CALL        GET_ASCIICODE   ; Get ASCII for button number
  34.         CALL        ESWRITE     ; Send ASCII over serial port
  35.         RETURN
  36.        
  37. GET_ASCIICODE   RLNCF   WREG            ; Multiplay WREG with 2
  38.         MOVWF   TBLPTRL         ; Load in to TABLPTRL
  39.         MOVLW   high(ASCIICODES)    ; Get high byte of code table
  40.         MOVWF   TBLPTRH         ; Load in to TABLEPTRH
  41.         TBLRD*              ; Fetch data from TABLPTR
  42.         MOVF    TABLAT, W       ; Load fetched data to work
  43.         RETURN     
  44.        
  45. GET_NRCODE  RLNCF   WREG            ; Multiplay WREG with 2
  46.         MOVWF   TBLPTRL         ; Load in to TABLPTRL
  47.         MOVLW   high(NUMBERCODES)   ; Get high byte of code table
  48.         MOVWF   TBLPTRH         ; Load in to TABLEPTRH
  49.         TBLRD*              ; Fetch data from TABLPTR
  50.         MOVF    TABLAT, W       ; Load fetched data to work
  51.         RETURN
  52.        
  53. NUMBERCODES org 0x500   ; 7seg TABLE
  54.         DB      B'00111111' ; 0
  55.         DB      B'00000110' ; 1
  56.         DB      B'01011011' ; 2
  57.         DB      B'01001111' ; 3
  58.         DB      B'01100110' ; 4
  59.         DB      B'01101101' ; 5
  60.         DB      B'01111100' ; 6
  61.         DB      B'00000111' ; 7
  62.         DB      B'01111111' ; 8
  63.         DB      B'01100111' ; 9
  64.         DB      B'01110111' ; A
  65.         DB      B'01111100' ; b
  66.         DB      B'00111001' ; C
  67.         DB      B'01011110' ; d
  68.         DB      B'01111001' ; E
  69.         DB      B'01110001' ; F
  70.        
  71. ASCIICODES  org 0x600   ; ASCII Table
  72.         DB      B'00110000' ; 0
  73.         DB      B'00110001' ; 1
  74.         DB      B'00110010' ; 2
  75.         DB      B'00110011' ; 3
  76.         DB      B'00110100' ; 4
  77.         DB      B'00110101' ; 5
  78.         DB      B'00110110' ; 6
  79.         DB      B'00110111' ; 7
  80.         DB      B'00111000' ; 8
  81.         DB      B'00111001' ; 9
  82.         DB      B'01000001' ; A
  83.         DB      B'01000010' ; b
  84.         DB      B'01000011' ; C
  85.         DB      B'01000100' ; d
  86.         DB      B'01000101' ; E
  87.         DB      B'01000110' ; F
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement