please dont rip this site

Atmel AVR Microcontroller Radix Conversions

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

;-----------------------------------------------------------------------------;
; Get value of hexdecimal string (32 bit)
;
; Register Variables:
;
;  Call:  X        -> Hexdecimal strings (space separated and EOL terminated)
;         var3:0   = <Don't care>
;         tmp1:0   = <Don't care> (high register must be assigned)
;
;  Result: ne,cc: Successful
;                 var3:0 = 32 bit result
;                 X -> Separater character
;          eq,cc: No data (reached EOL)
;                 var3:0 = 0
;                 X -> EOL
;          eq,cs: Invalid character is detected
;                 var3:0 = <Unknown>
;                 X -> Error character
;
; Size:  44 words
; Clock: depends on the string
; Stack: 0 byte


get_valh:
		clr	var0		;var = 0;
		clr	var1		;
		clr	var2		;
		clr	var3		;/
		ld	tmp0, X		;Skip " "
		cpi	tmp0, ' '	;
		brcc	PC+4		;
		clc	;no data	;
		sez	;		;
		ret	;/		;
		brne	PC+3		;
		adiw	XL, 1		;
		rjmp	PC-8		;/
					;--- processing loop
		cpi	tmp0, ' '+1	;convert a hexchar into its value
		brcc	PC+4		;
		clz	;successful	;
		clc	;		;
		ret	;/		;
		cpi	tmp0, 'a'	;
		brcs	PC+2		;
		subi	tmp0, 0x20	;
		subi	tmp0, '0'	;
		brcc	PC+4		;
		sec	;error		;
		sez	;		;
		ret	;/		;
		cpi	tmp0, 10	;
		brcs	PC+6		;
		subi	tmp0, 7		;
		cpi	tmp0, 10	;
		brcs	PC-7		;
		cpi	tmp0, 16	;
		brcc	PC-9		;/
		ldi	tmp1, 4		;var = var << 4 + tmp0;
		lsl	var0		;
		rol	var1		;
		rol	var2		;
		rol	var3		;
		dec	tmp1		;
		brne	PC-5		;
		or	var0, tmp0	;/
		adiw	XL, 1		;Next character
		ld	tmp0, X		;
		rjmp	PC-30		;/




file: /Techref/atmel/avr/asciihex2bin32b-ec.htm, 2KB, , updated: 2007/9/14 17:42, local time: 2024/11/25 01:55,
TOP NEW HELP FIND: 
18.219.176.215: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://massmind.org/Techref/atmel/avr/asciihex2bin32b-ec.htm"> Atmel AVR, atmega, Microcontroller, embedded controller, radix conversion, ASCII HEXDecimal 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 massmind.org!

 

Welcome to massmind.org!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .