piclist 2003\01\01\104804a >
Thread: fixed point to ASCII on 16F87x?
www.piclist.com/techref/microchip/devices.htm?key=16F
picon face BY : Bob Ammerman email (remove spam text)



; Here is a simplified version of the code.

; (untested and unoptimized)


; Subroutine to convert the 8 bit value 0..FF in W and display it on the LCD
;  On entry:
;        W is value to output

write_decimal:
                   movwf    temp2            ;save value to be output
                   movlw    100
                   call         dodigit
                   movlw    10
                   call         dodigit
                   movf      temp2,w
                   movwf    arg1
;                   call          sendlcddata    (note: we can replace a
call followed by
;                   return                             a return with a goto)
                   goto        sendlcddata

; Subroutine to generate one digit of the result and send it to the LCD:
;   On entry:
;    TEMP2 is the remaining value to output.
;    W is value of current digit, will be 100 or 10.

dodigit:
                  movwf    temp3
                  movlw    '0'                  ; init resulting digit to
'0'
                  movwf    arg1
loopdigit:
                  movf       temp3,w       ; get the 10 or 100
                  subwf      temp2,w        ; do the subtract, result in W
                  skpnc                           ; did the subtract work?
                  goto         sendlcddata  ; no, display the digit and
return
                  incf          arg1,f            ; increase the digit
value
                  movwf     temp2           ; store updated value in TEMP2
                  goto         loopdigit

Bob Ammerman
RAm Systems

--
http://www.piclist.com hint: To leave the PICList
spamBeGonepiclist-unsubscribe-requestspamBeGonespammitvma.mit.edu>
<002f01c2b1ac$e9357080$5800a8c0@DELL8100> 7bit

See also: www.piclist.com/techref/microchip/devices.htm?key=16F
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) fixed point to ASCII on 16F87x?

month overview.

new search...