From: Scott Dattalo
W_to_ascii:
mov bin, W ;added
clr hundreds
mov W, <>bin ;w = A0*16+A1
add W, bin ;w = A0+A1
and W, #00001111b ;w = A0+A1 % 16
mov tens_and_ones, W ;tens_and_ones = A0+A1 % 16
mov W, #$16
snb DC ;if A0+A1 > 16
add tens_and_ones, W ; tens_and_ones += 16
mov W, #$06
snb DC ;if tens_and_ones % 16 > 10
add tens_and_ones, W ; tens_and_ones += 6
add tens_and_ones, W ;tens_and_ones += 6
sb DC ;if tens_and_ones < 10
sub tens_and_ones, W ; tens_and_ones -= 6
mov W, #$16 - 1 + $6
snb bin.4
add tens_and_ones, W
mov W, #-$06
sb DC
add tens_and_ones, W
mov W, #$30
snb bin.5
add tens_and_ones, W
mov W, #$20
snb bin.7
add tens_and_ones, W
mov W, #$60
snb bin.6
add tens_and_ones, W
add tens_and_ones, W
rl hundreds
sb hundreds.0
sub tens_and_ones, W
snb bin.7
inc hundreds
;added (from here to bottom)
mov W, hundreds ;
or W, #$30 ;convert to ascii
call send_lcd ;hundreds to LCD
mov W, <>tens_and_ones
and W, #$0f
or W, #$30 ;always less than 0x0A
call send_lcd ;tens to LCD
mov W, tens_and_ones
and W, #$0f
or W, #$30
add W, Hack
call send_lcd ;ones to LCD
ret
See also:
| file: /Techref/scenix/lib/math/radix/bhp2ad-3d8b_sx.htm, 2KB, , updated: 2004/6/10 13:40, local time: 2012/2/10 16:11,
38.107.179.233:LOG IN |
| ©2012 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://www.piclist.com/techref/scenix/lib/math/radix/bhp2ad-3d8b_sx.htm"> SX Microcontroller Radix Math Method BCD half-packed to ASCII decimal 3 digit to 8 bit</A> |
| Did you find what you needed? |
|
Robotics nuts!Check out http://users.frii.com/dlc/robotics/projects/botproj.htm from Dennis Clark. This guy ROCKS! He has made (and sells but also releases code, docs, etc...) for a number of cool little robotic modules including whiskers, IR proximity detect and remote control, Sonar proximity detect, PWM, Servo, compass. Most of these use the little PIC 12C508 controller which costs basically nothing and is soooo tiny.The 4 servos, 2400 baud serial servo controller is a wonder of magic and he sells the programmed chip for $8. Wow! |
.