please dont rip this site

PIC Microcontoller Radix Math Method

Unpacked BCD to 16 bit binary conversion

;*******************************************************************************
; Input: unpacked BCD in  tenk:thou:hund:tens:ones
;Output: 16 bit binary in hi:lo
;  Size: 35 instructions
;Timing: 2+34+2=38 instruction cycles
;
; Notes:
;1) if input is higher than 65535 output is meaningless
;2) algorithm synopsis:
;
;> dec2bin([1 10 100 1000 1e4], 16)
;ans = 
;0000000000000001
;0000000000001010
;0000000001100100
;0000001111101000
;0010011100010000
;
;Or coded in three levels ('+' represents +1, '-' represents -1):
;000000000000000+ * ones +
;000000000000+0+0 * tens +
;000000000++00+00 * hund +
;00000+0000-0+000 * thou +
;00+0+00-000+0000 * tenk
;
;bin = (((tens+thou+tenk*256)*2+
;	hund+hund*16+thou*256)*2+
;	tens+hund*16-thou*16+tenk*16*256)*2+
;	ones+tenk*16-tenk*256
;
;January 24, 2001 by Nikolai Golovchenko
;*******************************************************************************

dec2bin16
	movf tens, w
	addwf thou, w
	movwf lo
	addwf lo, f
	rlf tenk, w
	movwf hi

	swapf hund, w
	addwf hund, w
	addwf lo, f
	movf thou, w
	addwf hi, f
	rlf lo, f
	rlf hi, f

	swapf hund, w
	addwf tens, w
	addwf lo, f
	swapf tenk, w
	skpnc
	 iorlw 0x01
	addwf hi, f
	swapf thou, w
	subwf lo, f
	skpc
	 decf hi, f
	clrc
	rlf lo, f
	rlf hi, f

	swapf tenk, w
	addwf ones, w
	addwf lo, f
	movf tenk, w
	skpnc
	 decf tenk, w
	subwf hi, f
	return
;*******************************************************************************

See also:


file: /Techref/microchip/math/radix/dec2bin16.htm, 1KB, , updated: 2001/1/26 11:34, local time: 2017/11/23 14:42, owner: NG--944,
TOP NEW HELP FIND: 
54.167.253.186:LOG IN

 ©2017 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://www.piclist.com/techref/microchip/math/radix/dec2bin16.htm"> Unpacked BCD to 16 bit binary conversion</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 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?

  PICList 2017 contributors:
o List host: MIT, Site host massmind.org, Top posters @20171123 RussellMc, Van Horn, David, James Cameron, Sean Breheny, alan.b.pearce, IVP, Neil, David C Brown, Bob Blick, Denny Esterline,
* 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.
 

Welcome to www.piclist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .