Code:
; BINARY TO ASCII ROUTINES ; this is NOT the smallest converter but its the fastest... ;*************************************************************** ; this table will convert 0 to 99 in binary to packed BCD ;*************************************************************** ; binary to packed bcd 00-99 7 bits only jump table bin2pak: addwf PCL,f retlw 0 retlw 1 retlw 2 retlw 3 retlw 4 retlw 5 retlw 6 retlw 7 retlw 8 retlw 9 retlw h'10' retlw h'11' retlw h'12' retlw h'13' retlw h'14' retlw h'15' retlw h'16' retlw h'17' retlw h'18' retlw h'19' retlw h'20' retlw h'21' retlw h'22' retlw h'23' retlw h'24' retlw h'25' retlw h'26' retlw h'27' retlw h'28' retlw h'29' retlw h'30' retlw h'31' retlw h'32' retlw h'33' retlw h'34' retlw h'35' retlw h'36' retlw h'37' retlw h'38' retlw h'39' retlw h'40' retlw h'41' retlw h'42' retlw h'43' retlw h'44' retlw h'45' retlw h'46' retlw h'47' retlw h'48' retlw h'49' retlw h'50' retlw h'51' retlw h'52' retlw h'53' retlw h'54' retlw h'55' retlw h'56' retlw h'57' retlw h'58' retlw h'59' retlw h'60' retlw h'61' retlw h'62' retlw h'63' retlw h'64' retlw h'65' retlw h'66' retlw h'67' retlw h'68' retlw h'69' retlw h'70' retlw h'71' retlw h'72' retlw h'73' retlw h'74' retlw h'75' retlw h'76' retlw h'77' retlw h'78' retlw h'79' retlw h'80' retlw h'81' retlw h'82' retlw h'83' retlw h'84' retlw h'85' retlw h'86' retlw h'87' retlw h'88' retlw h'89' retlw h'90' retlw h'91' retlw h'92' retlw h'93' retlw h'94' retlw h'95' retlw h'96' retlw h'97' retlw h'98' retlw h'99' ;************************************************************** ; 7-BIT BINARY TO 3-BYTE ASCII ; Mostly used to make binary to ASCII for Displays ; Input in 7 bits ; Output in ASCII: tmp1 (1s), tmp2 (10s), tmp (100s) ;************************************************************** bin2asc: andlw h'7f' ;7 bits only movwf tmp1 clrf tmp addlw d'256'-d'100' ;2s compl btfss status,c ;>99, subtract 100 goto bin2a incf tmp,f ;above 99, indicate 100s movwf tmp1 bin2a: movf tmp1,w call bin2pak ;bin to 2-packed bin 99 max ; ; exit here if all you need is packed BCD (h'00' to h'99') ; movwf tmp1 ;remainder converts packed BCD to 3-ASCII movwf tmp2 swapf tmp2,f movlw b'1111' andwf tmp1,f andwf tmp2,f movlw '0' addwf tmp1,f ;1's done addwf tmp2,f ;10's done addwf tmp,f ;100's done return ;***************************************************************** -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.+
file: /Techref/microchip/math/radix/b2a-7b3d-ba.htm, 4KB, , updated: 2004/7/12 01:59, local time: 2024/8/14 16:00,
owner: JMN-EFP-786,
3.133.115.92:LOG IN
|
©2024 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? <A HREF="http://piclist.com/techref/microchip/math/radix/b2a-7b3d-ba.htm"> Binary 7bit to ASCII decimal 3 digits by Bob Axtell</A> |
Did you find what you needed? |
![]() o List host: MIT, Site host massmind.org, Top posters @none found - 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 piclist.com! |
.