Truncated match.
PICList
Thread
'Anyone have 32 bit Binary to Ascii conversion code'
1996\10\02@114101
by
Ted Linn
One of the things I need to get a 16C57 to do is to convert a 32 bit binary
number to ascii for output to an LCD display. I know an algorithm for doing
this but being new to this pic world I wondered if anyone would share code
or offer some suggestions or 'tricks' that might be helpful for doing this.
Thanks
1996\10\05@152709
by
Ted Linn
One of the things I need to get a 16C57 to do is to convert a 32 bit binary
number to ascii for output to an LCD display. I know an algorithm for doing
this but being new to this pic world I wondered if anyone would share code
or offer some suggestions or 'tricks' that might be helpful for doing this.
Thanks
1996\10\06@163438
by
nogueira
|
Ted Linn wrote:
>
> One of the things I need to get a 16C57 to do is to convert a 32 bit binary
> number to ascii for output to an LCD display. I know an algorithm for doing
> this but being new to this pic world I wondered if anyone would share code
> or offer some suggestions or 'tricks' that might be helpful for doing this.
>
> Thanks
This routine converts a 32 bit binary number to BCD compacted,
to convert to ASCII just split the nibbles and add '0'
;******************************************************
; BIN2BCD
;RECEIVE BINARY NUMBER IN REG4,REG3,REG2,REG1 AND RETURN
DIG4,DIG3,DIG2,DIG1 AS BCD
;******************************************************
BIN2BCD
BCF STATUS,C
MOVLW 32
MOVWF COUNT
CLRF DIG6
CLRF DIG5
CLRF DIG4
CLRF DIG3
CLRF DIG2
CLRF DIG1
LOOP24 RLF REG1,1
RLF REG2,1
RLF REG3,1
RLF REG4,1
RLF DIG1,1
RLF DIG2,1
RLF DIG3,1
RLF DIG4,1
RLF DIG5,1
RLF DIG6,1
DECFSZ COUNT,1
GOTO ADJDEC
RETURN
ADJDEC
MOVLW DIG1
MOVWF FSR
CALL ADJBCD
MOVLW DIG2
MOVWF FSR
CALL ADJBCD
MOVLW DIG3
MOVWF FSR
CALL ADJBCD
MOVLW DIG4
MOVWF FSR
CALL ADJBCD
GOTO LOOP24
ADJBCD
MOVLW 3
ADDWF 0,W
MOVWF TEMP
BTFSC TEMP,3
MOVWF 0
MOVLW 0x30
ADDWF 0,W
MOVWF TEMP
BTFSC TEMP,7
MOVWF 0
RETLW 0
Octavio
--
========================================================
Octavio Nogueira
e-mail: spam_OUTnogueiraTakeThisOuT
mandic.com.br
homepage: http://ourworld.compuserve.com/homepages/tato
voice/fax: +55 11 240-6474
========================================================
"ProPic" The first Production PIC Programmer running in
Windows and under US$ 20.00.
Avaible at http://ourworld.compuserve.com/homepages/tato
More... (looser matching)
- Last day of these posts
- In 1996
, 1997 only
- Today
- New search...