please dont rip this site

Atmel AVR Microcontroller Radix Conversions

16bit to ASCII Decimal via output routine by http://elm-chan.org

;-----------------------------------------------------------------------------;
; Universal decimal string conversion (8/16 bit unsigned)
;
; Register Variables:
;  Call:   var1:0  = 16 bit value to be converted
;          len     = String length
;          tmp1:0  = <Don't care> (high register must be assigned)
;          tmp2    = <Don't care>
;
;  Result: var1:0  = <Unknown>
;          len     = <Not changed>
;          tmp1:0  = <Unknown>
;          tmp2    = 0
;
; Size:  30 words
; Clock: depends on output routine
; Stack: 10 bytes max (+output routine)
;
; Examples:   var1    len    output
;              100      0    "100"
;             1234      0    "1234"
;                0      7    "      0"
;              100      5    "  100"
;              100      2    "100"


mk_decu8:       clr     var1            ;8 bit entry
mk_decu16:                              ;16 bit entry
                clr     tmp2            ;digit counter
                inc     tmp2            ;---- decimal string generating loop
                clr     tmp0            ;var1 /= 10;
                ldi     tmp1,16         ;
                lsl     var0            ;
                rol     var1            ;
                rol     tmp0            ;
                cpi     tmp0,10         ;
                brcs    PC+3            ;
                subi    tmp0,10         ;
                inc     var0            ;
                dec     tmp1            ;
                brne    PC-8            ;/
                subi    tmp0,-'0'       ;Push the remander (a decimal digit)
                push    tmp0            ;/
                cp      var0,tmp1       ;if(var =! 0)
                cpc     var1,tmp1       ; continue digit loop;
                brne    PC-16           ;/
                cp      tmp2,len        ;Adjust string length (this can be removed for auto-length)
                brcc    PC+5            ;
                inc     tmp2            ;
                ldi     var0,' '        ;
                push    var0            ;
                rjmp    PC-5            ;/
                pop     var0            ;Put decimal string
                 rcall  xmit            ;<-- Put a char (var0) to memory, console or any display device
                dec     tmp2            ;
                brne    PC-3            ;/
                ret






file: /Techref/atmel/avr/bin2ascii16b-ec.htm, 2KB, , updated: 2007/9/14 18:32, local time: 2024/3/29 05:57,
TOP NEW HELP FIND: 
34.229.151.93: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?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://www.massmind.org/techref/atmel/avr/bin2ascii16b-ec.htm"> Atmel AVR, atmega, Microcontroller, embedded controller, radix conversion, 16bit to ASCII Decimal</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to massmind.org!

 

Welcome to www.massmind.org!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .