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 8bit
Author: Dingbat
This code was originally located @ http://www.piclist.com


Follow this link to go back

;--------------------------------------------------------------------+
; Function: Math : Multiply 16bits by 8bits |
;--------------------------------------------------------------------|
; Filename: M_MUL16x8.inc | Environment : MPLAB |
; Version : 1 | Microcontroller: PIC16F8x* |
; Date : 21/07/2003 | OSC MHz/MIPS : xx / xxx |
;--------------------------------------------------------------------|
; Author : Dingbat |
; Company : - |
; Files required : none |
;--------------------------------------------------------------------|

; Unsigned 16*8 bit Multiply AA(16) * BB(8), Result (CC) is 24bit
; adapted from code found on www.piclist.com
;
; params
; AA 0:1 (MSB:LSB) = number to multiply (16bit)
; BB = multiplier (8bit)
; CC 0:3 (MSB:LSB) = Product (24bit)
;
; Taking out the loops and inlining the code would save about
; another 20-30 instructions

MUL16x8
clrf CC+0 ;clear result
clrf CC+1 ;
clrf CC+2 ;
movlw .8
movwf bitCount ;bit counter set @ number of bits in multiplier

mul_L1 ;main loop here
rlf CC+2,f ;rotate result left (*2)
rlf CC+1,f ;
rlf CC+0,f ;
bcf CC+2,0 ;clear LSB of result after rotation
btfss BB,7 ;test msb of multipier
goto dontAdd ;if bit is clear then dont add
movfw AA+1 ;Add the 16 bits of AA to product
addwf CC+2,f ;
skpnc ;
incf CC+1,f ;
movfw AA ;
addwf CC+1,f ;
skpnc ;
incf CC+0,f ;
dontAdd
rlf BB,f ;rotate multiplier left
decfsz bitCount,f ;chk if finished all bits in multiplier
goto mul_L1

return

Follow this link to go back






delicious
digg
reddit this Reddit this
Faves



 HOT in heaven!