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


Follow this link to go back

LIST P = 16C54, n = 66
;
;*******************************************************************
; 8x8 Software Multiplier
; ( Fast Version : Straight Line Code )
;*******************************************************************
;
; The 16 bit result is stored in 2 bytes
;
; Before calling the subroutine " mpy ", the multiplier should
; be loaded in location " mulplr ", and the multiplicand in
; " mulcnd " . The 16 bit result is stored in locations
; H_byte & L_byte.
;
; Performance :
; Program Memory : 35 locations
; # of cycles : 37
; Scratch RAM : 0 locations
;
;
; Program: MULT8x8F.ASM
; Revision Date:
; 1-13-97 Compatibility with MPASMWIN 1.40
;
; This routine is optimized for speed efficiency ( straight line code )
; For code efficiency, refer to "mult8x8S.asm" ( looped code )
;*******************************************************************
;
mulcnd equ 09 ; 8 bit multiplicand
mulplr equ 10 ; 8 bit multiplier
H_byte equ 12 ; High byte of the 16 bit result
L_byte equ 13 ; Low byte of the 16 bit result
;
;
include "p16c5x.inc"

Same equ 1

;
;**** Define a macro for adding & right shifting **
;
mult MACRO bit ; Begin macro
btfsc mulplr,bit
addwf H_byte,Same
rrf H_byte,Same
rrf L_byte,Same
ENDM ; End of macro
;
; ***************************** Begin Multiplier Routine
mpy_F clrf H_byte
clrf L_byte
movf mulcnd,W ; move the multiplicand to W reg.
bcf STATUS,C ; Clear the carry bit in the status Reg.
mult 0
mult 1
mult 2
mult 3
mult 4
mult 5
mult 6
mult 7
;
retlw 0
;
;********************************************************************
; Test Program
;*********************************************************************
main movlw 0FF
movwf mulplr ; multiplier (in mulplr) = 0FF
movlw 0FF
movwf mulcnd ; multiplicand(in mulcnd ) = 0FF
;
call mpy_F ; The result 0FF*0FF = FE01 is in locations
; ; H_byte & L_byte
;
self goto self
;
org 01FF
goto main
;
END

Follow this link to go back






delicious
digg
reddit this Reddit this
Faves



 HOT in heaven!