please dont rip this site

SX Microcontroller Radix Math Method


Packed BCD to 16 bit binary conversion

;*******************************************************************************
;    Input: packed BCD in bcd2:bcd1:bcd0 (modified!)
;           bcd0 = tens:ones
;	    bcd1 = thou:hund
;           bcd2 = 0:tenk
;   Output: 16 bit binary in hi:lo
;Temporary: counter
;     Size: 23 instructions
;   Timing: 3+2+16*(6+12+4)-2+3=358 instruction cycles
;
; Notes: The routine uses BCD division by 2. Each iteration
;        the LSB of BCD value (which coincides with correspondent
;        binary bit) is shifted to output and BCD value is
;	 divided by 2. To do the division, BCD is shifted right
;        once and corrected. Correction: if MSB of a nibble is set,
;	 subtract 3 from it.
;
;January 22, 2001 by Nikolai Golovchenko
;*******************************************************************************
bcd2bin16
	mov	W, #16
	mov	counter, W
bcd2bin16loop
	clc
	rr	bcd2
	rr	bcd1
	rr	bcd0
	rr	hi
	rr	lo

	clr	W
	snb	bcd0.3
	or	W, #$03
	snb	bcd0.7
	or	W, #$30
	sub	bcd0, W
	clr	W
	snb	bcd1.3
	or	W, #$03
	snb	bcd1.7
	or	W, #$30
	sub	bcd1, W

	decsz	counter
	jmp	bcd2bin16loop
	ret
;*******************************************************************************

file: /techref/scenix/lib/math/radix/bcd2bin16.htm, 1KB, , updated: 2004/6/10 13:40, local time: 2008/12/5 02:37, owner: NG--944,
TOP NEW HELP FIND: 
38.103.63.58: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/scenix/lib/math/radix/bcd2bin16.htm"> Packed 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 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 @20081205 Apptech, Jinx, Xiaofan Chen, olin piclist, Vitaliy, William \Chops\ Westfield, Tamas Rudnai, JonnyMac, Alan B. Pearce, Gerhard Fiedler,
* 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

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .