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
48 bits by 24 Author: Andy Lee This code was originally located @ http://www.piclist.com
Follow this link to go back
;**************************************************************************
;Div4824U
;Inputs:
; Dividend - Dividend:6 (0 - least significant!)
; Divisor - Test:3 (0 - least significant!)
;Temporary:
; Counter - Count
; Shift - Shift:6
;Output:
; Quotient - Dividend:6 (0 - least significant!)
; Remainder- Rem:3 (0 - least significant!)
;
;Adaptation of 24x24 division by Tony Nixon with corrections
;by Frank Finster 3/15/2005.
;Code adapted by Andy Lee
;01-Sep-2006 Original version
;**************************************************************************
Div4824U:
;---------------------------------------------------
; SUBROUTINE - 48 by 24 BIT DIVISION
movlw 48
movwf Count
movff Dividend+0, Shift+0
movff Dividend+1, Shift+1
movff Dividend+2, Shift+2
movff Dividend+3, Shift+3
movff Dividend+4, Shift+4
movff Dividend+5, Shift+5
clrf Dividend+0
clrf Dividend+1
clrf Dividend+2
clrf Dividend+3
clrf Dividend+4
clrf Dividend+5
clrf Rem+2
clrf Rem+1
clrf Rem+0
dloop
bcf STATUS, C
rlcf Shift+0
rlcf Shift+1
rlcf Shift+2
rlcf Shift+3
rlcf Shift+4
rlcf Shift+5
rlcf Rem+0
rlcf Rem+1
rlcf Rem+2
movf Test+2, w
subwf Rem+2, w
btfss STATUS, Z
bra nochk
movf Test+1,w
subwf Rem+1,w
btfss STATUS, Z
bra nochk
movf Test+0,w
subwf Rem+0,w
nochk
btfss STATUS, C
bra nogo
movf Test+0,w
subwf Rem+0
btfsc STATUS, C
bra nodec_remainM
decf Rem+1, f
movf Rem+1, w
xorlw 0xff
btfsc STATUS, Z
decf Rem+2, f
nodec_remainM
movf Test+1, w
subwf Rem+1, f
btfss STATUS, C
decf Rem+2, f
movf Test+2, w
subwf Rem+2, f
bsf STATUS, C
nogo
rlcf Dividend+0
rlcf Dividend+1
rlcf Dividend+2
rlcf Dividend+3
rlcf Dividend+4
rlcf Dividend+5
decfsz Count, f
goto dloop
return |
Follow this link to go back
|
HOT in heaven!
|
|