please dont rip this site

Atmel AVR Microcontroller Radix Conversions

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

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


get_valu:
		clr	var0		;var = 0;
		clr	var1		;/
		ld	tmp0, X		;Skip " "
		cpi	tmp0, ' '	;
		brcc	PC+4		;
		clc	;no data	;
		sez	;		;
		ret	;/		;
		brne	PC+3		;
		adiw	XL, 1		;
		rjmp	PC-8		;/
					;--- digit processing loop
		cpi	tmp0, ' '+1	;convert a numeric char into its value
		brcc	PC+4		;
		clz	;successful	;
		clc	;		;
		ret	;		;
		subi	tmp0, '0'	;
		brcc	PC+4		;
		sec	;error		;
		sez	;		;
		ret	;/		;
		cpi	tmp0, 10	;
		brcc	PC-4		;/
		ldi	tmp1, 17	;var = var * 10 + tmp0;
		sub	tmp2, tmp2	;
		brcc	PC+2		;
		subi	tmp2, -10	;
		lsr	tmp2		;
		ror	var1		;
		ror	var0		;
		dec	tmp1		;
		brne	PC-6		;
		add	var0, tmp0	;
		adc	var1, tmp1	;/
		adiw	XL, 1		;Next character
		ld	tmp0, X		;
		rjmp	PC-25		;/




file: /Techref/atmel/avr/ascii2bin16b-ec.htm, 1KB, , updated: 2007/9/14 17:40, local time: 2024/12/24 23:01,
TOP NEW HELP FIND: 
18.191.54.190: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://linistepper.com/Techref/atmel/avr/ascii2bin16b-ec.htm"> Atmel AVR, atmega, Microcontroller, embedded controller, radix conversion, ASCII Decimal to 16bit</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?