;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
file: /Techref/scenix/lib/math/radix/b2a-16b4a-ng_sx.htm, 2KB, , updated: 2004/6/10 14:40, local time: 2024/8/16 17:05,
3.147.59.9:LOG IN
|
©2024 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://massmind.org/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? |
Welcome to massmind.org! |
Welcome to massmind.org! |
.