Home     Contact     Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science     RSS     Terms of services     Privacy policy  
   
 Home      Projects     Experiments     Circuits     Theory     BLOG     PIC Tutorials     Time for Science   



All about PIC microcontrollers

Within these pages, you can find many useful pieces of code mostly in assembly for the Microchip PIC micro controller family. A lot of people have spend many hours trying to put the bits and bytes together. If the code is NOT written by a member of the PCB Heaven community, then a link will be added above the code with the original website that this code was found.
Because the code is copied to our servers, you should know that:

  • The responsible web master of the website that the code is taken, has been informed and he has agreed to copy the code
  • All emails from the above contact have been kept as records but due to personal privacy cannot be shown in public.
  • The author of the code is always clearly indicated above the code. In some cases the author is unknown. If you happen to be the author of the code or you know the person who wrote it, please inform us by email and it will be added ASAP.

We would personally like to send the credits to all the people that managed to write some very interesting code and publish it, and special thanx to the people that originally hosted those code snippets and gave us the permission to copy them.


View code
Binary 7bit to ASCII decimal 3 digits
Author: Bob Axtell
This code was originally located @ http://www.piclist.com


Follow this link to go back

; 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
;*****************************************************************

Follow this link to go back






delicious
digg
reddit this Reddit this
Faves



 HOT in heaven!