please dont rip this site

Atmel AVR Microcontroller Radix Conversions

0/3707

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 18:41, local time: 2008/7/4 08:53,
TOP NEW HELP FIND: 
38.103.63.16:LOG IN
©2008 PLEASE DON'T RIP! DO: LINK / DIGG! / MAKE!

 ©2008 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!
<A HREF="http://www.piclist.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 reviewed) Just type in the box and press the Post button. (HTML welcomed!): 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: 
Did you find what you needed?

  PICList 2008 contributors:
o List host: MIT, Site host massmind.org, Top posters @20080704 Apptech, Jinx, Xiaofan Chen, David VanHorn, Alan B. Pearce, Bob Axtell, William \Chops\ Westfield, Cedric Chang, Gerhard Fiedler, bean,
* Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Shultz Electronics, Larry Williams, David VanHorn, Bryan Whitehouse, Timothy Weber, David Challis. Peter Todd. on-going support is MOST appreciated!
* Contributors: Neil Narwani, David Cary, Elemer AM Nyiry, Philip J Taylor, Gus Calabrese of Omegadogs.com, Gautama Venegas, Patrick B. Murphy, William Chops Westfield, Peter Todd, Leslie Ellis
  'What can I do?' - SiCKO

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .