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 
24bit X 24bit Author: Nikolai Golovchenko This code was originally located @ http://www.piclist.com
 
  Follow this link to go back
 
 cblock 
        Product:6 
        Multipland:3 
        BitCount:1 
        endc 
 
Multiplier EQU Product+3  ;3 bytes shared with Product's 
                          ;less significant bytes (+3..5) 
 
MULTIPLY_24x24 
        ; preload values to test 
        MOVLW   0xAB 
        MOVWF   Multipland 
        MOVLW   0xCD 
        MOVWF   Multipland+1 
        MOVLW   0xEF 
        MOVWF   Multipland+2 
 
        MOVLW   0x98 
        MOVWF   Multiplier 
        MOVLW   0x76 
        MOVWF   Multiplier+1 
        MOVLW   0x54 
        MOVWF   Multiplier+2 
 
        ; these values should generate the reply = 0x6651AF33BC6C 
 
 
;24 x 24 Multiplication 
;Input: 
; Multiplier - 3 bytes (shared with Product) 
; Multiplicand - 3 bytes (not modified) 
;Temporary: 
; Bitcount 
;Output: 
; Product - 6 bytes 
 
        CLRF    Product         ; clear destination 
        CLRF    Product+1 
        CLRF    Product+2 
 
         
        MOVLW   D'24' 
        MOVWF   BitCount        ; number of bits 
 
        RRF     Product+3,F
     ; shift out to carry 
        RRF     Product+4,F     ; next multiplier bit 
        RRF     Product+5,F 
 
ADD_LOOP_24x24 
 
        BTFSS   STATUS,C        ; if carry is set we must add multipland 
                                ; to the product 
          GOTO  SKIP_LOOP_24x24 ; nope, skip this bit 
                 
        MOVF    Multipland+2,W  ; get LSB of multiplicand 
        ADDWF   Product+2,F     ; add it to the lsb of the product 
   
        MOVF    Multipland+1,W  ; middle byte 
        BTFSC   STATUS,C        ; check carry for overflow 
        INCFSZ  Multipland+1,W  ; if carry set we add one to the source  
        ADDWF   Product+1,F     ; and add it  (if not zero, in 
                                ; that case mulitpland = 0xff->0x00 ) 
         
        MOVF    Multipland,W    ; MSB byte 
        BTFSC   STATUS,C        ; check carry 
        INCFSZ  Multipland,W 
        ADDWF   Product,F       ; handle overflow 
 
SKIP_LOOP_24x24 
        ; note carry contains most significant bit of 
        ; addition here 
 
        ; shift in carry and shift out 
        ; next multiplier bit, starting from less 
        ; significant bit 
 
        RRF     Product,F 
        RRF     Product+1,F 
        RRF     Product+2,F 
        RRF     Product+3,F 
        RRF     Product+4,F 
        RRF     Product+5,F 
 
        DECFSZ  BitCount,F 
        GOTO    ADD_LOOP_24x24 
        RETURN |  
  Follow this link to go back
 
 
 
 
  
 |  
 
  
   
  HOT in heaven!
  
 
 |  
 
 
 |