anlcd.asm.txt

(2 KB) Pobierz
; ANLCD.ASM
; Version 1.0
; For PIC 16C84
; 20th August 1998
; Typed by Ian Stedman
; Program to output data to an LCD display.
; PORTB, RB0-RB7 is 8 bit data to display.
; PORTA, RA0 is RS RA1 is Enable.
; Code listing from Maplin Magazine, May 1997 pages 14-18.

device  pic16c84
config      CP=off, WDT=off, PWRT=off, OSC=hs

include "picreg.h"

temp    equ     h'c'
temp2   equ     h'd'
csec    equ     h'e'

org     0
        goto start
org     4
        bsf     INTCON,RTIF
        movlw   h'80'
        call    COUT

        movlw   'H'
        call    DOUT
        movlw   'e'
        call    DOUT
        movlw   'l'
        call    DOUT
        movlw   'l'
        call    DOUT
        movlw   'o'
        call    DOUT
        movlw   ' '
        call    DOUT
        retfie

start   bcf     STATUS,RP0
        movlw   b'10100000'
        movwf   INTCON
        clrf    PORTB
        clrf    PORTA
        bsf     STATUS,RP0
        movlw   d'0'
        movwf   TRISB
        movwf   TRISA
        movlw   b'00000100'
        movwf   OPTIO
        bcf     STATUS,RP0
        clrf    csec

        ; set up display
        movlw   h'38'
        call    COUT

        clrf    temp2
        movlw   d'6'
        movwf   temp
st1     decfsz  temp2,F
        goto    st1
        decfsz  temp,F
        goto    st1

        movlw   h'38'
        call    COUT

        movlw   d'20'
        movwf   temp
st2     decfsz  temp,F
        goto    st2

        movlw   h'38'
        call    COUT
        movlw   h'38'
        call    COUT

        movlw   h'06'
        call    COUT
        movlw   h'0C'
        call    COUT
        movlw   h'01'
        call    COUT

        movlw   d'2'
        movwf   temp
st3     decfsz  temp2,F
        goto    st3
        decfsz  temp,F
        goto    st3

loop    nop
        goto    loop

        ; Display Routines

COUT    bcf     PORTA,0
        goto    out1
DOUT    bsf     PORTA,0
out1    movwf   PORTB
        bsf     PORTA,1
        bcf     PORTA,1

        movlw   d'13'
        movwf   temp
out2    decfsz  temp,F
        goto    out2
        return

        END

Zgłoś jeśli naruszono regulamin