PIC Microcontoller Radix Math Method

BCD half-packed to ASCII decimal 3 digit to 8 bit

From: Scott Dattalo

W_to_ascii:

	mov	bin, W	;added

	clr	hundreds
	mov	W, <>bin
	add	W, bin
	and	W, #00001111b
	snb	DC
;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. 
;         ADDLW  0x16
	mov	Hack, W
	mov	W, #$16
	add	W, Hack
	snb	DC
;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. 
;         ADDLW  0x06
	mov	Hack, W
	mov	W, #$06
	add	W, Hack
;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. 
;        ADDLW   0x06
	mov	Hack, W
	mov	W, #$06
	add	W, Hack
	sb	DC
;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. 
;         ADDLW  -0x06
	mov	Hack, W
	mov	W, #-$06
	add	W, Hack

	snb	bin.4
;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. 
;         ADDLW   0x16 - 1 + 0x6
	mov	Hack, W
	mov	W, #$16 - 1 + $6
	add	W, Hack
	sb	DC
;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. 
;         ADDLW  -0x06
	mov	Hack, W
	mov	W, #-$06
	add	W, Hack

	snb	bin.5
;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. 
;         ADDLW  0x30
	mov	Hack, W
	mov	W, #$30
	add	W, Hack

	snb	bin.6
;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. 
;         ADDLW  0x60
	mov	Hack, W
	mov	W, #$60
	add	W, Hack

	snb	bin.7
;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. 
;         ADDLW  0x20
	mov	Hack, W
	mov	W, #$20
	add	W, Hack

;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. 
;        ADDLW   0x60
	mov	Hack, W
	mov	W, #$60
	add	W, Hack
	rl	hundreds
	sb	hundreds.0
;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. 
;         ADDLW  -0x60
	mov	Hack, W
	mov	W, #-$60
	add	W, Hack

	mov	tens_and_ones, W
	snb	bin.7
	inc	hundreds

                                ;added (from here to bottom)
	mov	W, hundreds	;
;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. 
;        addlw   0x30            ;convert to ascii
	mov	Hack, W
	mov	W, #$30	;convert to ascii
	add	W, Hack
	call	send_lcd	;hundreds to LCD

	mov	W, <>tens_and_ones	;
	and	W, #$0f	;
;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. 
;        addlw   0x30            ;always less than 0x0A
	mov	Hack, W
	mov	W, #$30	;always less than 0x0A
	add	W, Hack
	call	send_lcd	;tens to LCD

	mov	W, tens_and_ones	;
	and	W, #$0f	;
;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. 
;        addlw   0x30            ;
	mov	Hack, W
	mov	W, #$30	;
	add	W, Hack
	call	send_lcd	;ones to LCD

	ret	;