please dont rip this site

PIC JAL Math Routine

Bin2Bcd3 converts Binary number to BCD

by Vasile Surducan

-- --------------------------------------------------
--      Bin2Bcd3(var bcd2..bcd0 , bin1..bin0)
--  converts BIN number in bin1 .. bin0
--  to BCD out bcd2 .. bcd0
--
--  bcd2:msd, bcd1:isd, bcd0:lsd, bin1:msb, bin0:lsb
-- --------------------------------------------------


Procedure AdjBcd(Byte in out digit) is
Var byte temp 
var bit hc at temp : 3 
var bit fc at temp : 7 
	  temp = digit + 3
	  if hc then digit = temp end if
	  temp = digit + 0x30
	  if fc then digit = temp end if
End procedure

procedure bin2bcd3 (byte out bcd2,byte out bcd1,byte out bcd0,
                    Byte in bin1 ,Byte in bin0)  is

	bcd2 = 0
	bcd1 = 0
	bcd0 = 0
    for 16 loop			   -- all (16) bits of bin0..bin2
      AdjBcd(bcd0)		 	  
      AdjBcd(bcd1)		  
      AdjBcd(bcd2)
      
	  Assembler			   
	    rlf bin0,f
	    rlf bin1,f
	    rlf bcd0,f
	    rlf bcd1,f
	    rlf bcd2,f
	   
      End Assembler
    End loop
End procedure

See also:


file: /Techref/piclist/jal/bin2bcd3.htm, 1KB, , updated: 2000/10/25 15:15, local time: 2017/12/15 09:53,
TOP NEW HELP FIND: 
54.227.127.109: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/piclist/jal/bin2bcd3.htm"> PIC JAL Math Routine </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 @20171215 RussellMc, Van Horn, David, Sean Breheny, James Cameron, alan.b.pearce, IVP, Neil, Bob Blick, David C Brown, John Gardner,
* 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!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .