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		;
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		;
ld	tmp0, X		;
rjmp	PC-25		;/

```

 file: /Techref/atmel/avr/ascii2bin16b-ec.htm, 1KB, , updated: 2007/9/14 18:40, local time: 2024/5/23 13:59, TOP NEW HELP FIND:  44.222.189.51: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! Atmel AVR, atmega, Microcontroller, embedded controller, radix conversion, ASCII Decimal to 16bit

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.

Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
 Did you find what you needed? "No. I'm looking for: " "No. Take me to the search page." "No. Take me to the top so I can drill down by catagory" "No. I'm willing to pay for help, please refer me to a qualified consultant"

 PICList 2024 contributors: o List host: MIT, Site host massmind.org, Top posters @none found - 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: Gregg Rew. on-going support is MOST appreciated! * Contributors: Richard Seriani, Sr.

.