please dont rip this site

PIC Microcontoller Math Library Methods

Conversion of Millimeters to Inches

To convert Millimeters to Inches, Divide by 25.4 or multiply by .03937.


For an eight bit value...

; ACC = ACC * 0.03937
; Temp = TEMP
; ACC size = 8 bits
; Error = 0.5 %
; Bytes order = little endian
; Round = no

; Clear accumulator
; Add input / 32 to accumulator
; Add input / 128 to accumulator
; Add input / 4096 to accumulator
; Move accumulator to result
; Approximated constant: 0.0393066, Error: 0.160933 %

;     Input: ACC0, 8 bits
;    Output: ACC0, 4 bits
; Code size: 20 instructions


;copy accumulator to temporary
	movf	ACC0, w
	movwf	TEMP0

;shift accumulator right 5 times
	swapf	ACC0, w
	andlw	0x0F
	movwf	ACC0
	rrf	ACC0, f

;add temporary to accumulator
	movf	TEMP0, w
	addwf	ACC0, f

;shift accumulator right 2 times
	rrf	ACC0, f
	rrf	ACC0, f

;add temporary to accumulator
	addwf	ACC0, f

;shift accumulator right 5 times
	swapf	ACC0, w
	andlw	0x0F
	movwf	ACC0
	bsf	ACC0, 4
	rrf	ACC0, f

; Generated by (November 17, 2000 version)
; Tue Apr 03 14:37:32 2001 GMT

file: /Techref/microchip/math/convmilinch.htm, 1KB, , updated: 2001/4/3 09:39, local time: 2024/5/27 15:21,

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF=""> PIC Microcontoller Math Library Methods for Conversion of Millimeters to Inches</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.

Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

  PICList 2024 contributors:
o List host: MIT, Site host, Top posters @none found
- Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.

Welcome to!