;Thanks Scott, your code is very instructive.
;Total execution time:
;worst case: 59 + 80 + 66 + 46 = 251 cycles
;Code size: 73
clr temp
sub30k
mov W, #3
add temp, W
mov W, #30000 & $FF
sub Lo, W
mov W, #30000 >> 8
sb C
mov W, #(30000 >> 8) + 1
sub Hi, W
snb C
jmp sub30k
add10k
dec temp
mov W, #10000 & $FF
add Lo, W
mov W, #(10000 >> 8)
snb C
mov W, #(10000 >> 8) + 1
add Hi, W
sb C
jmp add10k
; Output(temp) ;output temp = TenK
;worst case: 12 * 3 + 11 * 3 - 1 = 59
clr temp
sub3k
mov W, #3
add temp, W
mov W, #3000 & $FF
sub Lo, W
mov W, #(3000 >> 8)
sb C
mov W, #(3000 >> 8) + 1
sub Hi, W
snb C
jmp sub3k
add1k
dec temp
mov W, #1000 & $FF
add Lo, W
mov W, #(1000 >> 8)
snb C
mov W, #(1000 >> 8) + 1
add Hi, W
sb C
jmp add1k
; Output(temp) ;output temp = Thou
;worst case: 12 * 4 + 11 * 3 - 1 = 80
clr temp
sub300
mov W, #3
add temp, W
mov W, #300 & $FF
sub Lo, W
mov W, #(300 >> 8)
sb C
mov W, #(300 >> 8) + 1
sub Hi, W
snb C
jmp sub300
mov W, #100
add100
dec temp
add Lo, W
sb C
jmp add100
inc Hi
snb Hi.7
jmp add100
; Output(temp) ;output temp = Hund
;worst case: 11 * 4 + 6 * 3 + 3 = 66
clr temp
mov W, #30
sub30
inc temp
sub Lo, W
snb C
jmp sub30
mov W, temp
rl temp
add temp, W
mov W, #10
add10
dec temp
add Lo, W
sb C
jmp add10
; Output(temp) ;output temp = Tens
;worst case: 6 * 4 + 6 * 3 + 4 = 46
; Output(Lo) ;output temp = Ones
See also:
| file: /Techref/scenix/lib/math/radix/b2a-16b4a-ng_sx.htm, 2KB, , updated: 2004/6/10 14:40, local time: 2012/5/17 02:42,
38.107.179.207: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.sxlist.com/techref/scenix/lib/math/radix/b2a-16b4a-ng_sx.htm"> SX Microcontroller Radix Math Method - Binary to ASCII, 16 bit to 5 digits (1 at a time) no temp register</A> |
| Did you find what you needed? |
sales, advertizing, & kind contributors just like you! Please don't rip/copy (here's why Copies of the site on CD are available at minimal cost. |
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! |
.