;***************************************************************************
;                                                                     
;	8 Bit Binary Output on LCD Display for PIC 16XXX
;	================================================
;
;	written by Peter Luethi, 02.08.1999, Dietikon, Switzerland
;	http://www.electronic-engineering.ch
;	last update: 20.08.2004
;
;	V1.00:	Initial release (02.08.1999)
;
;	This code and accompanying files may be distributed freely and
;	modified, provided this header with my name and this notice remain
;	intact. Ownership rights remain with me.
;	You may not sell this software without my approval.
;
;	This software comes with no guarantee or warranty except for my
;	good intentions. By using this code you agree to indemnify me from
;	any liability that might arise from its use.
;
;	
;	SPECIFICATIONS:
;	===============
;	Processor:		Microchip PIC 16XXX
;	Binary Range:		8 Bit
;
; 
;	DESCRIPTION:
;	============
;	Developed on PIC 16C84, but executeable on all PIC 16XXX.
;	Displays the 8 bit binary value stored in LO on the
;	LCD display in binary format.
;	This routine is only used for debugging registers and bit-
;	streams.
;	
;
;	NOTE:
;	=====
;	Call of implemented procedure with:
;		"LCDbin_08", value in LO
;
;	LO is not altered or cleared during operation and is
;	still valid after termination of this routine.
;	During the whole routine, LO_TEMP and b08_cnt must NOT be
;	used by other routines !		      ========
;
;
;	DECLARATIONS needed in MAIN PROGRAM :
;	=====================================
;	CONSTANT BASE = 0x0C	; Base address of user file registers
;	b08_cnt equ	BASE+?	; counter
;	LO	equ	BASE+?
;	LO_TEMP	equ	BASE+?
;
;
;	REQUIRED MEMORY:
;	================
;	3 registers declared in main program.
;	needs itself 1 stack level, but LCDw needs some more
;
;***************************************************************************

;***** INCLUDE FILES *****

	IFNDEF	M_LCD_ID
	  ERROR "Missing include file: m_lcd.asm or similar"
	ENDIF
	
;***** REGISTER DECLARATION *****

	IFNDEF	b08_cnt
	  ERROR "ModuleError: Declare b08_cnt in MAIN PROGRAM"
	ENDIF
	IFNDEF	LO
	  ERROR "ModuleError: Declare LO in MAIN PROGRAM"
	ENDIF
	IFNDEF	LO_TEMP
	  ERROR "ModuleError: Declare LO_TEMP in MAIN PROGRAM"
	ENDIF

;***** MACROS *****
	
LCDbin_08 macro
	call LCDbin08
	endm
	
;***** SUB-ROUTINES *****

LCDbin08
	movfw	LO
	movwf	LO_TEMP
	movlw	d'8'
	movwf	b08_cnt
bin_loop08
	movlw	'0'
	btfsc	LO_TEMP,7	; check if bit is set, skip if cleared
	movlw	'1'
	LCDw			; call LCD sub-routine with data stored in w
	rlf	LO_TEMP,1
	decfsz	b08_cnt,1
	goto	bin_loop08
	RETURN

