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 18:42, local time: 2008/8/28 08:35,
TOP NEW HELP FIND: 
38.103.63.61: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/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 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 @20080828 Apptech, Jinx, Xiaofan Chen, olin piclist, Alan B. Pearce, Vitaliy, William \Chops\ Westfield, Tamas Rudnai, Cedric Chang, David VanHorn,
* 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, Timothy Weber, on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.
  'What can I do?' - SiCKO

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .