please dont rip this site

PIC Microcontoller Radix Math Method

10bit to BCD unpacked 3 digit in 25 inst 28 cycles (for PIC's with hardware multiplier only)

by Djula Djarmati

;**********************************************************************************************
;CONVERT 10-BIT BINARY TO THREE DECIMAL DIGITS (28 cycles, 25 program 
memory)
;Input word:    Digits+1:Digits
;Output digits: Digits+2:Digits+1:Digits
;Trashes:       PRODH, PRODL
;**********************************************************************************************
Bin_To_Dec_999  movlw   d'41'                   ;Multiply by 0.01 (41/4096)
                mulwf   Digits+1                ;
                movff   PRODL, Digits+2         ;
                mulwf   Digits                  ;
                movf    PRODH, w                ;
                addwf   Digits+2, w             ;
                mullw   0x10                    ;Lose the lower 8 bits 
and shift
                movf    PRODH, w                ;result 4 bits left 
(divide by 4096)
                movwf   Digits+2                ;Save result
                mullw   d'100'                  ;and then multiply it 
by 100
                movf    PRODL, w                ;
                subwf   Digits, f               ;Subtract from original
                movf    PRODH, w                ;to get
                subwfb  Digits+1, f             ;remainder
                movf    Digits, w               ;Split remainder (0-99) 
to two decimals
                mullw   D'205'                  ;
                movlw   D'32'                   ;Multiply by 0.1
                mulwf   PRODH                   ;(205/256 * 32/256)
                movf    PRODH, w                ;
                movwf   Digits+1                ;Save result
                mullw   D'10'                   ;and then multiply it by 10
                movf    PRODL, w                ;Subtract from original
                subwf   Digits, f               ;Save remainder
                return                          ;Done

See also:


file: /Techref/microchip/math/radix/b2bu-10b3d-mullw-dd.htm, 2KB, , updated: 2011/3/6 17:07, local time: 2017/11/24 18:10,
TOP NEW HELP FIND: 
54.156.92.243:LOG IN

 ©2017 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="http://www.piclist.com/techref/microchip/math/radix/b2bu-10b3d-mullw-dd.htm"> PIC Microcontoller Radix Math Method 10bit to BCD unpacked 3 digit in 25 inst 28 cycles by Djula Djarmati </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 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 2017 contributors:
o List host: MIT, Site host massmind.org, Top posters @20171124 RussellMc, Van Horn, David, James Cameron, Sean Breheny, alan.b.pearce, IVP, Neil, David C Brown, Bob Blick, Denny Esterline,
* 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 www.piclist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .