; Progam STRING_3.ASM
;
; Illustrates how to display variables in decimal using the PIC-n-LCD.
;
; Note that 16H and 17H are special characters that casue the next value
; to be printed in either signed or unsigned decimal.
;
; N is continually incremented and displayed in both signed and unsigned
; form.
;
; Note that this uses program LCD_CTRL.ASM which is included at the bottom
; of this program.
;
; PORTA, Bit 0 (terminal 17) ------ TX ----------> to RX on Serial LCD
;
; copyright, Peter H. Anderson, Morgan State University, July 5, '97

	LIST p=16f84	

#include <c:\mplab\p16f84.inc>	
	__CONFIG 11h

	CONSTANT VARS=0CH

N		EQU VARS+0
	
LOOP1		EQU VARS+1
LOOP2		EQU VARS+2

	ORG 000H

MAIN:
	BSF STATUS, RP0		; RP1 = 0, RP0 = 1, BANK1
	BCF TRISA, 0		; make RA.0 an output		
	BCF STATUS, RP0		; bank 0
	BCF PORTA, 0		; serial lead at 0

	CLRF N

TOP:
	MOVLW 0CH	; clear LCD
	CALL LCD_CHAR
	
	MOVLW 16H	; print next character as a signed character
	CALL LCD_CHAR

	MOVF N, W
	CALL LCD_CHAR

	MOVLW 09H	; tab
	CALL LCD_CHAR

	MOVLW 17H	; print the next character as an unsigned quan
	CALL LCD_CHAR

	MOVF N, W
	CALL LCD_CHAR

	CALL DELAY
	
	INCF N, F	; increment N
	GOTO TOP
	

DELAY:	MOVLW	.250
	MOVWF	LOOP1		
OUTTER:
	MOVLW	.110	; close to 1.0 msec delay when set to .110
	MOVWF 	LOOP2
INNER:
	NOP
	NOP
	NOP
	NOP
	NOP
	NOP
	DECFSZ	LOOP2, F
	GOTO INNER
	DECFSZ 	LOOP1, F
	GOTO OUTTER
	RETURN


#include <a:\lcd_ctrl.asm>	

	END