ВходНаше всё Теги codebook 无线电组件 Поиск Опросы Закон Суббота
27 апреля
49289 Топик полностью
Sinelogic (25.01.2006 11:40, просмотров: 1) ответил Dingo на BIN2BCD можно шустрей как-нить? На 2313 делаю. почти 2000 циклов.
Ответ: 
hex2bcd:
;hex to bcd conversion input r1:r2:r3:r4,output	r2:r3:r4:r5
		push	xl
		push	xh
		push	yh
		push	yl
		clr		xl
		clr		xh
		clr		yl
		clr		yh
		ldi		r17,32
		mov		r5,r17
		clr		r17
hex2bcd_loop:
		rol		r4
		rol		r3
		rol		r2
		rol		r1
		rol		yh
		rol		yl
		rol		xh
		rol		xl
		dec		r5
		brne	hex2bcd1
		mov		r2,xl
		mov		r3,xh
		mov		r4,yl
		mov		r5,yh
		pop		yh
		pop		yl
		pop		xh
		pop		xl
		ret		
hex2bcd1:
		subi	xl,-3
		sbrs	xl,3
		subi	xl,3
		subi	xl,-0x30
		sbrs	xl,7
		subi	xl,0x30
		subi	xh,-3
		sbrs	xh,3
		subi	xh,3
		subi	xh,-0x30
		sbrs	xh,7
		subi	xh,0x30
		subi	yl,-3
		sbrs	yl,3
		subi	yl,3
		subi	yl,-0x30
		sbrs	yl,7
		subi	yl,0x30
		subi	yh,-3
		sbrs	yh,3
		subi	yh,3
		subi	yh,-0x30
		sbrs	yh,7
		subi	yh,0x30
		rjmp	hex2bcd_loop