———

 
Translations of this page:

char2num - Convert 1 character hex code to number

char2num
	local	noLowerCase
	local	convError
	local	digit
 
	movwf	temp
 
	sublw	'F'
	skipneg
	goto noLowerCase
 
	movlw	'a'-'A'
	subwf	temp, f
	movlw	temp
 
noLowerCase
	;test if the symbol i sless than '0': if sym - '0' >= 0 -> ok
	movlw	'0'
	subwf	temp, w	; temp - w
	skippz
	goto	convError
 
	; test if sym > 'F': if sym-'F'+1 >=0 -> error
	movlw	'F'+1
	subwf	temp, w
	skipneg
	goto	convError
 
	movlw	'A'
	subwf	temp, w
	skippz
	goto	digit
	addlw	0x0A
	return
 
digit
	movlw	'0'
	subwf	temp, w
	return
 
convError
	movlw	0x00
	return
 
mcu/pic16/char2num.txt · Last modified: 03.28.2010 23:27 by npelov
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki