please dont rip this site

Atmel AVR Microcontroller Radix Conversions

ASCII Decimal to 32bit via input routine by http://elm-chan.org

;-----------------------------------------------------------------------------;
; Get value of decimal string (32 bit signed)
;
; Register Variables:
;
;  Call:  X       -> Decimal strings (Space separated, EOL (<0x20) terminated)
;         var3:0  = <Don't care>
;         tmp2:0  = <Don't care> (high register must be assigned)
;
;  Result: ne,cc: Successful
;                 var3:0 = 32 bit result
;                 X -> Space or EOL
;          eq,cc: No data (EOL)
;                 var3:0 = 0
;                 X -> EOL
;          eq,cs: Invalid character is detected
;                 var3:0 = Unknown
;                 X -> Error character
;
; Size:  56 words
; Clock: depends on the source
; Stack: 0 byte


get_vals:
		clr	var0		;var = 0;
		clr	var1		;
		clr	var2		;
		clr	var3		;/
		clt			;Skip " " and "-"
		ld	tmp0, X		;
		cpi	tmp0, ' '	;
		brcc	PC+4		;
		clc	;no data	;
		sez	;		;
		ret	;/		;
		breq	PC+4		;
		cpi	tmp0, '-'	;
		brne	PC+4		;
		set			;
		adiw	XL, 1		;
		rjmp	PC-11		;/
					;--- digit processing loop
		cpi	tmp0, ' '+1	;convert a numeric char into its value
		brcc	PC+13		;
		brtc	PC+9		;
		com	var0		;
		com	var1		;
		com	var2		;
		com	var3		;
		adc	var0, tmp1	;
		adc	var1, tmp1	;
		adc	var2, tmp1	;
		adc	var3, tmp1	;
		clz	;Successful	;
		clc	;		;
		ret	;/		;
		subi	tmp0, '0'	;
		brcc	PC+4		;
		sec	;Error		;
		sez	;		;
		ret	;/		;
		cpi	tmp0, 10	;
		brcc	PC-4		;/
		ldi	tmp1, 33	;var = var * 10 + tmp0;
		sub	tmp2, tmp2	;
		brcc	PC+2		;
		subi	tmp2, -10	;
		lsr	tmp2		;
		ror	var3		;
		ror	var2		;
		ror	var1		;
		ror	var0		;
		dec	tmp1		;
		brne	PC-8		;
		add	var0, tmp0	;
		adc	var1, tmp1	;
		adc	var2, tmp1	;
		adc	var3, tmp1	;/
		adiw	XL, 1		;Next character
		ld	tmp0, X		;
		rjmp	PC-38		;/





file: /Techref/atmel/avr/ascii2bin32b-ec.htm, 2KB, , updated: 2007/9/14 17:41, local time: 2024/11/30 17:58,
TOP NEW HELP FIND: 
3.139.98.10: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://sxlist.com/TECHREF/atmel/avr/ascii2bin32b-ec.htm"> Atmel AVR, atmega, Microcontroller, embedded controller, radix conversion, ASCII Decimal to 32bit</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 sxlist.com!


Site supported by
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.
 

Welcome to sxlist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .