NybbletoASCII                   ;  Convert a Nybble in "w" to ASCII

  addlw  0x036                  ;  Add '0' + 6 to Value
  btfsc  STATUS, DC             ;  If Digit Carry Set, then 'A' - 'F'
   addlw 7                      ;   Add Difference Between '9' and 'A'
  addlw  0-6

  return                        ;  Return the ASCII of Digit in "w"


ByteToASCII                     ;  Convert a Byte to two ASCII Bytes using
                                ;   "NybbletoASCII"

  movwf  tmp_out1                   ;  Save the Byte to Convert for Lower Nybble

  swapf  tmp_out1,W                 ;  Move the High Nybble into "w"
  andlw  0x00F
  call   NybbletoASCII
  call lcd_put_char


  movf   tmp_out1,W
  andlw  0x007                  ;  Convert the Low Nybble
  call   NybbletoASCII
  call lcd_put_char

  return

IntToASCII
  movwf tempthree

  movlw '('
  call lcd_put_char
  movf tempthree, W
  call ByteToASCII
  movlw ')'
  call lcd_put_char
  return

HexToASCII
  movwf	tempthree

  movlw	'['
  call lcd_put_char
  movlw	'0'
  call lcd_put_char
  movlw	'x'
  call lcd_put_char
  movf tempthree, W
  call ByteToASCII
  movlw	']'
  call lcd_put_char
  return

Hex2BCD
	movwf   tmp_out1
	clrw
	btfsc   tmp_out1, 4
	addlw   0x16
	btfsc   tmp_out1, 5
	addlw   0x32
	addlw   0x06
	skpdc
	addlw   -0x06
	btfsc   tmp_out1, 6
	addlw   0x64
	addlw   0x06
	skpdc
	addlw   -0x06
	movwf   temptwo
	movf    tmp_out1, 0
	andlw   0x0F
	addwf   tmp_out2, 0
	skpndc
	addlw   0x06
	addlw   0x06
	skpdc
	addlw   -0x06
	return

Bin2BCD: 
	movwf	bin
        CLRF    hundreds 
        SWAPF   bin, W          ;w  = A0*16+A1
        ADDWF   bin, W          ;w  = A0+A1
        ANDLW   00001111b       ;w  = A0+A1 % 16
        SKPNDC                  ;if A0+A1 > 16
         ADDLW  0x16            ;  w  += 16
        SKPNDC                  ;if w % 16 > 10
         ADDLW  0x06            ;  w  += 6
        ADDLW   0x06            ;w  += 6
        SKPDC                   ;if w < 10
         ADDLW  -0x06           ;  w  -= 6

        BTFSC   bin,4 
         ADDLW   0x16 - 1 + 0x6 
        SKPDC 
         ADDLW  -0x06 

        BTFSC   bin, 5 
         ADDLW  0x30 

        BTFSC   bin, 6 
         ADDLW  0x60 

        BTFSC   bin, 7 
         ADDLW  0x20 

        ADDLW   0x60 
        RLF     hundreds, F 
        BTFSS   hundreds, 0 
         ADDLW  -0x60 

        MOVWF   tens_and_ones 
;        BTFSC   bin,7 
 ;        INCF   hundreds, F
	return


; Converts Celcius to Farenheight
cel_to_feh:
;
; Code to evaluate expression: "(temp*9/5)+32"
;
; Automatically generated by http://www.markworld.com/evaluate8.html
;
	movwf	tmp_out1

        movlw   9       ;load constant
        movwf   MpyDiv1 ;multiplier
        movf    tmp_out1,W  ;load operand
        LONG_CALL    Mpy8x8  ;return product in MpyDiv2
        movf    MpyDiv2,W
        movwf   Scratch
        movlw   5       ;load constant
        movwf   MpyDiv1 ;divisor
        movf    Scratch,W     ;dividend
        LONG_CALL    Div8x8  ;return quotient in MpyDiv2
        movf    MpyDiv2,W
        movwf   Scratch
        movlw   32      ;load constant
        addwf   Scratch,W
	return
;
; The result is in W
;

