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
16bit X 16bit Signed
Author: Malin
This code was originally located @ http://www.piclist.com


Follow this link to go back

;signed multiply of a2:a1 with b2:b1 leaving result in res4:res3:res2:res1
; These 8 variables need to be defined, as does neg_flag
;
; Program length 64 lines
; time 134 to 248 cycles
; This program looks at the lsb of a1 to decide whether to add b1 to res2
;
; and b2 to res3, with appropriate carrys
; It then looks at the lsb of a2 to decide whether to add b1 to res3 and
; b2 to res4, again with appropriate carrys.
; The rotates then only have to be done 8 times
;
; This is uses slightly more program but takes a little less time than
; a routine that performs one 16 bit addition per rotate and 16 rotates
;
; Multiple byte addition routine from Microchip AN617
; Result registers used as loop counter from Bob Fehrenbach & Scott Dattalo
;


clrf res4
clrf res3
clrf res2
movlw 0x80
movwf res1

clrf neg_flag

btfss a2,7
goto a_pos
comf a2,f
comf a1,f
incf a1,f
btfsc status, zero
incf a2,f
incf neg_flag, f
a_pos
btfss b2,7
goto nextbit
comf b2,f
comf b1,f
incf b1,f
btfsc status, zero
incf b2,f
incf neg_flag, f

nextbit
rrf a2,f
rrf a1,f

btfss status, carry
goto nobit_l
movf b1,w
addwf res2,f

movf b2, w
btfsc status, carry
incfsz b2, w
addwf res3, f
btfsc status, carry
incf res4, f
bcf status, carry

nobit_l
btfss a1, 7
goto nobit_h
movf b1,w
addwf res3,f
btfsc status, carry
incf res4,f
movf b2,w
addwf res4,f
nobit_h
rrf res4,f
rrf res3,f
rrf res2,f
rrf res1,f

btfss status, carry
goto nextbit
btfss neg_flag, 0
goto no_invert

comf res4,f
comf res3,f
comf res2,f
comf res1,f

incf res1,f
btfsc status,zero
incf res2,f
btfsc status,zero
incf res3,f
btfsc status,zero
incf res4,f
no_invert

Follow this link to go back






delicious
digg
reddit this Reddit this
Faves



 HOT in heaven!