please dont rip this site

PIC Microcontoller Radix Math Method

Binary to ASCII, 8 bit to 3 digits

-Remove-a.borowski@spam@ at student.qut.edu.au shares this code:

Here's a nice bit of code that turns a 8 bit binary number into it's hundreds, tens and ones in ASCII, suitable for displaying. Simply put your number in 'bin', call BIN2BCD, then use huns, tens and ones for display.
BIN2BCD

;---------------------


;in: BIN
;out huns. tens, ones

;uses ADD-3 algoerthm

movlw 8
movwf count
clrf huns
clrf tens
clrf ones

BCDADD3

movlw 5
subwf huns, 0
btfsc STATUS, C
CALL ADD3HUNS

movlw 5
subwf tens, 0
btfsc STATUS, C
CALL ADD3TENS

movlw 5
subwf ones, 0
btfsc STATUS, C
CALL ADD3ONES

decf count, 1
bcf STATUS, C
rlf BIN, 1
rlf ones, 1
btfsc ones,4 ; 
CALL CARRYONES
rlf tens, 1

btfsc tens,4 ; 
CALL CARRYTENS
rlf huns,1
bcf STATUS, C

movf count, 0
btfss STATUS, Z
GOTO BCDADD3


movf huns, 0 ; add ASCII Offset
addlw h'30'
movwf huns

movf tens, 0 ; add ASCII Offset
addlw h'30'
movwf tens

movf ones, 0 ; add ASCII Offset
addlw h'30'
movwf ones

RETURN

ADD3HUNS

movlw 3
addwf huns,1

RETURN

ADD3TENS

movlw 3
addwf tens,1

RETURN

ADD3ONES

movlw 3
addwf ones,1

RETURN

CARRYONES
bcf ones, 4
bsf STATUS, C
RETURN

CARRYTENS
bcf tens, 4
bsf STATUS, C
RETURN

Comments:

See also:


file: /Techref/microchip/math/radix/b2a-8b3d-ab.htm, 2KB, , updated: 2014/12/3 08:33, local time: 2017/11/22 21:33,
TOP NEW HELP FIND: 
54.166.188.64: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/b2a-8b3d-ab.htm"> PIC Microcontoller Radix Math Method Binary to ASCII, 8 bit to 3 digits </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 @20171122 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!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .