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
8 bit by 8bit to 24bit floating point
Author: Nikolai Golovchenko
This code was originally located @ http://www.piclist.com


Follow this link to go back

;***********************************************
;Floating point division of two unsigned integer
;8 bit variables
;
;Input: AARGB0 - dividend (nominator)
; BARGB0 - divisor (denominator)
;Output:
; AEXP, AARGB0, AARGB1 - quotient
; (MICROCHIP format - AN575)
; w = 0 on success
; w = 1 error: divide by zero
;Temporaries:
; BARGB1
;
;RAM - 5 bytes
;ROM - 41 words
;Speed - 7 + 4 + 8 * 9 + 4 + 14 * 23 + 4 = 413 instruction
; cycles worst case (including call and return)
;***********************************************
fdiv24_8_8
movfw BARGB0
skpnz
retlw 1 ;divide by zero
clrf AEXP
movfw AARGB0
skpnz
retlw 0 ;zero result
;loop to use all 8 bits of dividend (integer 8 by 8 divide)
movwf AARGB1
clrf BARGB1
movlw 0x08
movwf AARGB0 ;aargb0 is used as loop counter
fdiv24_8_8b
rlf AARGB1, f
rlf BARGB1, f
movfw BARGB0
subwf BARGB1, w
skpnc
movwf BARGB1
decfsz AARGB0, f
goto fdiv24_8_8b
rlf AARGB1, f ;aargb1 is the integer quotient so far
;loop to fill all the bits of 16bit mantissa
clrf AARGB0
movlw 0x8E
movwf AEXP
clrc
fdiv24_8_8c
rlf BARGB1, f
movfw BARGB0
skpc ;check carry (9th bit)
goto fdiv24_8_8d
subwf BARGB1, f
setc
goto fdiv24_8_8e
fdiv24_8_8d
subwf BARGB1, w
skpnc
movwf BARGB1
fdiv24_8_8e
rlf AARGB1, f
rlf AARGB0, f
decf AEXP, f
btfss AARGB0, 7
goto fdiv24_8_8c
bcf AARGB0, 7 ;replace explicit msb with sign
retlw 0
;***********************************************

Follow this link to go back






delicious
digg
reddit this Reddit this
Faves



 HOT in heaven!